gornostal / Modific

Highlight lines changed since the last commit (supports Git, SVN, Bazaar, Mercurial and TFS) / ST2(3) plugin
614 stars 44 forks source link

if set console_encoding , cause exception. #95

Open clijiac opened 9 years ago

clijiac commented 9 years ago

exception as below. when i click a file of svn. the sublime console show this error. have try set console_encoding to gbk or gb2312 even utf_8.

Exception in thread Thread-17:
Traceback (most recent call last):
  File "./threading.py", line 901, in _bootstrap_inner
  File "Modific in D:\SmallTools\Sublime3\Data\Installed Packages\Modific.sublime-package", line 172, in run
  File "./subprocess.py", line 824, in __init__
  File "./subprocess.py", line 1071, in _execute_child
  File "./subprocess.py", line 632, in list2cmdline
TypeError: Type str doesn't support the buffer API
gornostal commented 9 years ago

@clijiac , could you provide more info?

clijiac commented 9 years ago
gornostal commented 9 years ago

I'll try to take a look at this issue next week.

clijiac commented 9 years ago

do not know much about python and sublime plugin. but I have done some reasearch. hope this may help you:) change code from line 165. add some print to see info

            print(self.console_encoding)
            print(self.command)
            if self.console_encoding:
                self.command = [s.encode(self.console_encoding) for s in self.command]

            print(self.command)
            print(self.command,self.stdout,shell,subprocess.STDOUT,subprocess.PIPE,subprocess)
            proc = subprocess.Popen(self.command,
                                    stdout=self.stdout, stderr=subprocess.STDOUT,
                                    stdin=subprocess.PIPE,
                                    shell=shell, universal_newlines=False)
            print(self.stdin,proc.communicate(self.stdin))

here is the output with console_encoding

Modific: run command: svn diff --internal-diff addsportleague.js
gb2312
['svn', 'diff', '--internal-diff', 'addsportleague.js']
[b'svn', b'diff', b'--internal-diff', b'addsportleague.js']
[b'svn', b'diff', b'--internal-diff', b'addsportleague.js'] -1 True -2 -1 <module 'subprocess' from 'D:\\SmallTools\\Sublime3\\python3.3.zip\\subprocess.pyo'>
Exception in thread Thread-131:
Traceback (most recent call last):
  File "./threading.py", line 901, in _bootstrap_inner
  File "D:\SmallTools\Sublime3\Data\Packages\Modific\Modific.py", line 176, in run
    shell=shell, universal_newlines=False)
  File "./subprocess.py", line 824, in __init__
  File "./subprocess.py", line 1071, in _execute_child
  File "./subprocess.py", line 632, in list2cmdline
TypeError: Type str doesn't support the buffer API

here is the output without console_encoding ,delete some diff info of my project code .this condition looks good

['svn', 'diff', '--internal-diff', 'addsportleague.js']
['svn', 'diff', '--internal-diff', 'addsportleague.js']
['svn', 'diff', '--internal-diff', 'addsportleague.js'] -1 True -2 -1 <module 'subprocess' from 'D:\\SmallTools\\Sublime3\\python3.3.zip\\subprocess.pyo'>
None (b"Index: addsportleague.js\r\n===================================================================\r\n--- addsportleague.js\t(revision 0)\
===================================================================
gornostal commented 9 years ago

I looked into it, but could not figure out what may cause that issue. Why do you need to set console_encoding? What happens if you don't set it?