diff --git a/test/bytecode_2.6/03_if_vs_and.pyc b/test/bytecode_2.6/03_if_vs_and.pyc new file mode 100644 index 00000000..6d935caf Binary files /dev/null and b/test/bytecode_2.6/03_if_vs_and.pyc differ diff --git a/test/bytecode_2.6/06_return_pop.pyc b/test/bytecode_2.6/06_return_pop.pyc-notyet similarity index 100% rename from test/bytecode_2.6/06_return_pop.pyc rename to test/bytecode_2.6/06_return_pop.pyc-notyet diff --git a/test/simple_source/bug26/03_if_vs_and.py b/test/simple_source/bug26/03_if_vs_and.py new file mode 100644 index 00000000..5d67dfec --- /dev/null +++ b/test/simple_source/bug26/03_if_vs_and.py @@ -0,0 +1,22 @@ +# From 2.6 decimal +# Bug was not recognizing scope of if and +# turning it into xc == 1 and xe *= yc +def _power_exact(y, xc, yc, xe): + yc, ye = y.int, y.exp + while yc % 10 == 0: + yc //= 10 + ye += 1 + + if xc == 1: + xe *= yc + while xe % 10 == 0: + xe //= 10 + ye += 1 + if ye < 0: + return None + exponent = xe * 10**ye + if y and xe: + xc = exponent + else: + xc = 0 + return 5 diff --git a/uncompyle6/main.py b/uncompyle6/main.py index 1955fae8..fd2a8d55 100644 --- a/uncompyle6/main.py +++ b/uncompyle6/main.py @@ -134,12 +134,14 @@ def main(in_base, out_base, files, codes, outfile=None, uncompyle_file(infile, outstream, showasm, showast, showgrammar) tot_files += 1 except (ValueError, SyntaxError, ParserError, pysource.SourceWalkerError) as e: - sys.stderr.write("\n# file %s\n# %s" % (infile, e)) + sys.stdout.write("\n") + sys.stderr.write("\n# file %s\n# %s\n" % (infile, e)) failed_files += 1 except KeyboardInterrupt: if outfile: outstream.close() os.remove(outfile) + sys.stdout.write("\n") sys.stderr.write("\nLast file: %s " % (infile)) raise # except: diff --git a/uncompyle6/semantics/check_ast.py b/uncompyle6/semantics/check_ast.py index 67be0090..8bca0411 100644 --- a/uncompyle6/semantics/check_ast.py +++ b/uncompyle6/semantics/check_ast.py @@ -12,9 +12,9 @@ def checker(ast, in_loop, errors): in_loop = in_loop or ast.type in ('while1stmt', 'whileTruestmt', 'whilestmt', 'whileelsestmt', 'for_block') - if ast.type == 'augassign1' and ast[0][0] == 'and': - text = str(ast[0]) - error_text = '\n# improper augmented assigment:\n#\t' + '\n# '.join(text.split("\n")) + if ast.type in ('augassign1', 'augassign2') and ast[0][0] == 'and': + text = str(ast) + error_text = '\n# improper augmented assigment (e.g. +=, *=, ...):\n#\t' + '\n# '.join(text.split("\n")) + '\n' errors.append(error_text) for node in ast: diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index f7b32fa6..33898b46 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -2324,7 +2324,7 @@ def deparse_code(version, co, out=sys.stdout, showasm=None, showast=False, deparsed.write('# global %s ## Warning: Unused global' % g) if deparsed.ast_errors: - deparsed.write("# NOTE: have decompilation errors.\n") + deparsed.write("# NOTE: have internal decompilation grammar errors.\n") deparsed.write("# Use -t option to show full context.") for err in deparsed.ast_errors: deparsed.write(err)