From b6e53205dd96f725e3984d305c08465baa183fba Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 13 Nov 2016 18:55:23 -0500 Subject: [PATCH] Handle verify syntax errors... Update README.rst stats --- README.rst | 8 +++++--- uncompyle6/verify.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 86f69825..b0269ec7 100644 --- a/README.rst +++ b/README.rst @@ -100,11 +100,13 @@ The biggest known and possibly fixable (but hard) problem has to do with handling control flow. In some cases we can detect an erroneous decompilation and report that. -About 90% of the decompilation verifies from Python 2.3.7 to Python -3.4.2 on the standard library packages I have on my system. +About 90% of the decompilation of Python standard library packages in +Python 2.7.12 verifies correctly. Over 99% of Python 2.7 and 3.3-3.5 +"weakly" verify. Python 2.6 drops down to 96% weakly verifying. +Other versions drop off in quality too. *Verification* is the process of decompiling bytecode, compiling with -a Python for that byecode version, and then comparing the bytecode +a Python for that bytecode version, and then comparing the bytecode produced by the decompiled/compiled program. Some allowance is made for inessential differences. But other semantically equivalent differences are not caught. For example ``if x: foo()`` is diff --git a/uncompyle6/verify.py b/uncompyle6/verify.py index 260ec247..f021e79a 100755 --- a/uncompyle6/verify.py +++ b/uncompyle6/verify.py @@ -395,7 +395,10 @@ def compare_code_with_srcfile(pyc_filename, src_filename, weak_verify=False): msg = ("Can't compare code - Python is running with magic %s, but code is magic %s " % (PYTHON_MAGIC_INT, magic_int)) return msg - code_obj2 = load_file(src_filename) + try: + code_obj2 = load_file(src_filename) + except SyntaxError as e: + return str(e) cmp_code_objects(version, is_pypy, code_obj1, code_obj2, ignore_code=weak_verify) return None