Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Fix for working with python3 (ST3) #216

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/", line 276, in split
File "X/", line 266, in next
File "X/", line 93, in get_token
File "X/", line 121, in read_token
AttributeError: 'bytes' object has no attribute 'read'

Thus it's required to decode the string.

Fredrik Ehnbom

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

    vigsterkr authored
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 internals/
7 internals/
@@ -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)
- 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.