X Tutup
Skip to content

Commit ccd129b

Browse files
committed
Try stronger verification
verify.py: add check in verification that magic is the same. Otherwise we go for weak verification.
1 parent c03a818 commit ccd129b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

test/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ check-3.2: check-bytecode
3232

3333
#: Run working tests from Python 3.3
3434
check-3.3: check-bytecode
35-
$(PYTHON) test_pythonlib.py --bytecode-3.3 --weak-verify $(COMPILE)
35+
$(PYTHON) test_pythonlib.py --bytecode-3.3 --verify $(COMPILE)
3636

3737
#: Run working tests from Python 3.4
3838
check-3.4: check-bytecode check-3.4-ok check-2.7-ok
39-
$(PYTHON) test_pythonlib.py --bytecode-3.4 --weak-verify $(COMPILE)
39+
$(PYTHON) test_pythonlib.py --bytecode-3.4 --verify $(COMPILE)
4040

4141
#: Run working tests from Python 3.5
4242
check-3.5: check-bytecode
43-
$(PYTHON) test_pythonlib.py --bytecode-3.5 --weak-verify $(COMPILE)
43+
$(PYTHON) test_pythonlib.py --bytecode-3.5 --verify $(COMPILE)
4444

4545
#: Run working tests from Python 3.6
4646
check-3.6: check-bytecode
47-
$(PYTHON) test_pythonlib.py --bytecode-3.6 --weak-verify $(COMPILE)
47+
$(PYTHON) test_pythonlib.py --bytecode-3.6 --verify $(COMPILE)
4848

4949
#: Check deparsing only, but from a different Python version
5050
check-disasm:

uncompyle6/verify.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ def compare_code_with_srcfile(pyc_filename, src_filename, weak_verify=False):
400400

401401
def compare_files(pyc_filename1, pyc_filename2, weak_verify=False):
402402
"""Compare two .pyc files."""
403-
version, timestamp, magic_int1, code_obj1, is_pypy = uncompyle6.load_module(pyc_filename1)
404-
version, timestamp, magic_int2, code_obj2, is_pypy = uncompyle6.load_module(pyc_filename2)
405-
cmp_code_objects(version, is_pypy, code_obj1, code_obj2, ignore_code=weak_verify)
403+
version1, timestamp, magic_int1, code_obj1, is_pypy = uncompyle6.load_module(pyc_filename1)
404+
version2, timestamp, magic_int2, code_obj2, is_pypy = uncompyle6.load_module(pyc_filename2)
405+
weak_verify = weak_verify or (magic_int1 != magic_int2)
406+
cmp_code_objects(version1, is_pypy, code_obj1, code_obj2, ignore_code=weak_verify)
406407

407408
if __name__ == '__main__':
408409
t1 = Token('LOAD_CONST', None, 'code_object _expandLang', 52)

0 commit comments

Comments
 (0)
X Tutup