Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for working with python3 (ST3) #216

Closed
wants to merge 4 commits into from

2 participants

Viktor Gal Fredrik Ehnbom
Viktor Gal

shlex.split cannot handle bytes, and since python3 does not ignore anymore the b prefix of the strings (to the contrary of python 2.x), shlex.split will fail like this:
....
opts += shlex.split(output[0])
File "X/shlex.py", line 276, in split
File "X/shlex.py", line 266, in next
File "X/shlex.py", line 93, in get_token
File "X/shlex.py", line 121, in read_token
AttributeError: 'bytes' object has no attribute 'read'

Thus it's required to decode the string.

Fredrik Ehnbom
Owner

Won't that break ST2? I've changed it to use the helper functions I created to manage the differences between st2 and st3 instead. Could you try and see if that works for you?

Viktor Gal

this patch works fine as well... thnx

Fredrik Ehnbom quarnster closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2013
  1. Viktor Gal

    Fix for python3 (ST3)

    vigsterkr authored
Commits on Mar 8, 2013
  1. Viktor Gal

    Merge branch 'master' of github.com:vigsterkr/SublimeClang

    vigsterkr authored
    Conflicts:
    	internals/translationunitcache.py
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 internals/translationunitcache.py
7 internals/translationunitcache.py
View
@@ -26,7 +26,8 @@
from .common import Worker, complete_path, expand_path, get_setting, get_path_setting,\
get_language, LockedVariable, run_in_main_thread, error_message,\
- display_user_selection, get_cpu_count, status_message, bencode, bdecode, are_we_there_yet
+ display_user_selection, get_cpu_count, status_message, bencode, bdecode,\
+ sencode, sdecode, are_we_there_yet
from .clang import cindex
from .parsehelp.parsehelp import *
@@ -1251,14 +1252,14 @@ def get_translation_unit(self, filename, opts=[], opts_script=None, unsaved_file
if opts_script:
# shlex.split barfs if fed with an unicode strings
- args = shlex.split(opts_script.encode()) + [filename]
+ args = shlex.split(sencode(opts_script)) + [filename]
process = subprocess.Popen(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
output = process.communicate()
if process.returncode:
print("The options_script failed with code [%s]" % process.returncode)
print(output[1])
else:
- opts += shlex.split(output[0])
+ opts += shlex.split(bdecode(output[0]))
if self.debug_options:
print("Will compile file %s with the following options:\n%s" % (filename, opts))
Something went wrong with that request. Please try again.