From a30f3625ac9c21f7e11e90026d49be81a6c36c0d Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 29 Dec 2015 22:10:05 -0500 Subject: [PATCH] Fix Python 2 cross deparsing pythond bytecode tuples co_consts, co_names, co_varnames. Reinstate cross Python 2-3 uncompiling --- test/Makefile | 2 +- uncompyle6/marsh.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Makefile b/test/Makefile index 2ec0ab0a..2f2530ad 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 diff --git a/uncompyle6/marsh.py b/uncompyle6/marsh.py index 120fa7c0..43196fda 100644 --- a/uncompyle6/marsh.py +++ b/uncompyle6/marsh.py @@ -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: