From ccd129b3777391fbb4e2c91ff36bf964c24a58e4 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 25 Sep 2016 17:48:33 -0400 Subject: [PATCH] Try stronger verification verify.py: add check in verification that magic is the same. Otherwise we go for weak verification. --- test/Makefile | 8 ++++---- uncompyle6/verify.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index 00193788..073633ce 100644 --- a/test/Makefile +++ b/test/Makefile @@ -32,19 +32,19 @@ check-3.2: check-bytecode #: Run working tests from Python 3.3 check-3.3: check-bytecode - $(PYTHON) test_pythonlib.py --bytecode-3.3 --weak-verify $(COMPILE) + $(PYTHON) test_pythonlib.py --bytecode-3.3 --verify $(COMPILE) #: Run working tests from Python 3.4 check-3.4: check-bytecode check-3.4-ok check-2.7-ok - $(PYTHON) test_pythonlib.py --bytecode-3.4 --weak-verify $(COMPILE) + $(PYTHON) test_pythonlib.py --bytecode-3.4 --verify $(COMPILE) #: Run working tests from Python 3.5 check-3.5: check-bytecode - $(PYTHON) test_pythonlib.py --bytecode-3.5 --weak-verify $(COMPILE) + $(PYTHON) test_pythonlib.py --bytecode-3.5 --verify $(COMPILE) #: Run working tests from Python 3.6 check-3.6: check-bytecode - $(PYTHON) test_pythonlib.py --bytecode-3.6 --weak-verify $(COMPILE) + $(PYTHON) test_pythonlib.py --bytecode-3.6 --verify $(COMPILE) #: Check deparsing only, but from a different Python version check-disasm: diff --git a/uncompyle6/verify.py b/uncompyle6/verify.py index 0a98f4ae..69b4488d 100755 --- a/uncompyle6/verify.py +++ b/uncompyle6/verify.py @@ -400,9 +400,10 @@ def compare_code_with_srcfile(pyc_filename, src_filename, weak_verify=False): def compare_files(pyc_filename1, pyc_filename2, weak_verify=False): """Compare two .pyc files.""" - version, timestamp, magic_int1, code_obj1, is_pypy = uncompyle6.load_module(pyc_filename1) - version, timestamp, magic_int2, code_obj2, is_pypy = uncompyle6.load_module(pyc_filename2) - cmp_code_objects(version, is_pypy, code_obj1, code_obj2, ignore_code=weak_verify) + version1, timestamp, magic_int1, code_obj1, is_pypy = uncompyle6.load_module(pyc_filename1) + version2, timestamp, magic_int2, code_obj2, is_pypy = uncompyle6.load_module(pyc_filename2) + weak_verify = weak_verify or (magic_int1 != magic_int2) + cmp_code_objects(version1, is_pypy, code_obj1, code_obj2, ignore_code=weak_verify) if __name__ == '__main__': t1 = Token('LOAD_CONST', None, 'code_object _expandLang', 52)