You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
More AST checking
Small fixes in output format
This commit is contained in:
BIN
test/bytecode_2.6/03_if_vs_and.pyc
Normal file
BIN
test/bytecode_2.6/03_if_vs_and.pyc
Normal file
Binary file not shown.
22
test/simple_source/bug26/03_if_vs_and.py
Normal file
22
test/simple_source/bug26/03_if_vs_and.py
Normal file
@@ -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
|
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user