Sublime Forum

UnicodeDecodeError

#1

Hi! The problem be about darrenderidder’s JSLint plugin (I’ve opened the issue there too, but doubt that it’s an issue of the plugin itself) and russian (unicode) letters in full path to user’s %APPDATA% folder (where Sublime Text 2 packages reside). Whenever I run the plugin, I have the following in Sublime Text 2 console:

I’ve edited line 45 of exec.py file, which I was able to find in Packages\Default folder. I changed this:

to that:

And now I have the following in the console:

I couldn’t find the location of the subprocess.py. I suspect it is in-memory module. So I need your help! :wink:

0 Likes

#2

My guess is that’s the cyrillic char. in the path that cause the issue.
You must try adding something like that before line 47:

for index, arg in enumerate(arg_list:]): arg_list[index] = arg.encode(sys.getfilesystemencoding()

It’s a file from standard Python distribution, which is compiled and zipped in ST on Windows.
If you install Python (http://www.python.org/), you can find it under Lib directory.

0 Likes

#3

[quote=“bizoo”]You must try adding something like that before line 47:

for index, arg in enumerate(arg_list:]): arg_list[index] = arg.encode(sys.getfilesystemencoding()
[/quote]

That solved the problem! Thank you so much!

0 Likes

#4

I have the same problem but the fix didn’t solve it. It’s also being caused by special chars.

I’m getting this error

[quote]Running node C:\Users\João Moura\AppData\Roaming\Sublime Text 2\Packages/JSLint/linter.js --predef ‘angular’, ‘document’, ‘$’, '’, ‘JQuery’, ‘FB’] --sloppy --indent 2 --node --nomen --vars --plusplus --stupid --todo C:\Users\João Moura\Documents\ISEL\7º Semestre\PI\javascript\aula14\marvilaUnit.js
Traceback (most recent call last):
File “.\sublime_plugin.py”, line 337, in run

File “.\exec.py”, line 154, in run
File “.\exec.py”, line 45, in init
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe3 in position 11: ordinal not in range(128)[/quote]

After changing lines 44-45 from exec.py from

Before - Default (lines 44-45)

for k, v in proc_env.iteritems(): proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())

After (lines 44-50)

[code]for k, v in proc_env.iteritems():
proc_env[k] = os.path.expandvars(v.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding())
for index, arg in enumerate(arg_list:]):
arg_list[index] = arg.encode(sys.getfilesystemencoding())

    self.proc = subprocess.Popen(arg_list, stdout=subprocess.PIPE,
        stderr=subprocess.PIPE, startupinfo=startupinfo, env=proc_env, shell=shell)[/code]

It’s still not working after this and when I save de javascript file I’m getting this error

[quote]Running node C:\Users\João Moura\AppData\Roaming\Sublime Text 2\Packages/JSLint/linter.js --predef ‘angular’, ‘document’, ‘$’, ‘’, ‘JQuery’, ‘FB’] --sloppy --indent 2 --node --nomen --vars --plusplus --stupid --todo C:\Users\João Moura\Documents\ISEL\7º Semestre\PI\javascript\aula14\marvilaUnit.js
Traceback (most recent call last):
File “.\sublime_plugin.py”, line 337, in run

File “.\exec.py”, line 160, in run
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xe3’ in position 11: ordinal not in range(128)[/quote]

This is the part of the code from exec.py file that is messing up now (bold and underlined is line 160)

try: # Forward kwargs to AsyncProcess self.proc = AsyncProcess(cmd, merged_env, self, **kwargs) except err_type as e: self.append_data(None, str(e) + "\n") self.append_data(None, "[cmd: " + str(cmd) + "]\n") ** self.append_data(None, "[dir: " + str(os.getcwdu()) + "]\n")** if "PATH" in merged_env: self.append_data(None, "[path: " + str(merged_env["PATH"]) + "]\n") else: self.append_data(None, "[path: " + str(os.environ["PATH"]) + "]\n") if not self.quiet: self.append_data(None, "[Finished]") "[Finished]")

Can someone please help?

0 Likes