Fix Python 2 cross deparsing pythond bytecode tuples co_consts,

co_names, co_varnames. Reinstate cross Python 2-3 uncompiling
This commit is contained in:
rocky
2015-12-29 22:10:05 -05:00
parent e17d94f28f
commit a30f3625ac
2 changed files with 4 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ check:
$(MAKE) check-$$PYTHON_VERSION
#: Run working tests from Python 2.6 or 2.7
check-2.6 check-2.7: check-bytecode-2 check-2.7-ok
check-2.6 check-2.7: check-bytecode check-2.7-ok
#: Run working tests from Python 3.3
check-3.3: check-bytecode

View File

@@ -126,9 +126,9 @@ def load_code_type(fp, magic_int, bytes_for_s=False, code_objects={}):
if (3000 <= magic_int < 20121):
# Python 3 encodes some fields as Unicode while Python2
# requires the corresponding field to have string values
co_consts = tuple([str(s) if s else None for s in co_consts])
co_names = tuple([str(s) if s else None for s in co_names])
co_varnames = tuple([str(s) if s else None for s in co_varnames])
co_consts = tuple([str(s) if isinstance(s, unicode) else s for s in co_consts])
co_names = tuple([str(s) if isinstance(s, unicode) else s for s in co_names])
co_varnames = tuple([str(s) if isinstance(s, unicode) else s for s in co_varnames])
co_filename = str(co_filename)
co_name = str(co_name)
if 3020 < magic_int <= 20121: