You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Small tweaks...
add-test.py: wasn't handling optimize correctly. Handle python version better parse27.py: dyslexia 01_for_else_try_else.py: bug in found in 1.4 anydbm.py which we will address soon
This commit is contained in:
@@ -5,6 +5,7 @@ import os, sys, py_compile
|
|||||||
|
|
||||||
assert len(sys.argv) >= 2
|
assert len(sys.argv) >= 2
|
||||||
version = sys.version[0:3]
|
version = sys.version[0:3]
|
||||||
|
vers = sys.version_info[:2]
|
||||||
if sys.argv[1] in ("--run", "-r"):
|
if sys.argv[1] in ("--run", "-r"):
|
||||||
suffix = "_run"
|
suffix = "_run"
|
||||||
py_source = sys.argv[2:]
|
py_source = sys.argv[2:]
|
||||||
@@ -20,6 +21,9 @@ for path in py_source:
|
|||||||
cfile = "bytecode_%s%s/%s" % (version, suffix, short) + "c"
|
cfile = "bytecode_%s%s/%s" % (version, suffix, short) + "c"
|
||||||
print("byte-compiling %s to %s" % (path, cfile))
|
print("byte-compiling %s to %s" % (path, cfile))
|
||||||
optimize = 2
|
optimize = 2
|
||||||
py_compile.compile(path, cfile, optimize=optimize)
|
if vers >= (3, 0):
|
||||||
if isinstance(version, str) or version >= (2, 6, 0):
|
py_compile.compile(path, cfile, optimize=optimize)
|
||||||
|
else:
|
||||||
|
py_compile.compile(path, cfile)
|
||||||
|
if vers >= (2, 6):
|
||||||
os.system("../bin/uncompyle6 -a -T %s" % cfile)
|
os.system("../bin/uncompyle6 -a -T %s" % cfile)
|
||||||
|
BIN
test/bytecode_2.7_run/01_for_else_try_else.pyc
Normal file
BIN
test/bytecode_2.7_run/01_for_else_try_else.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.7_run/01_for_else_try_else.pyc
Normal file
BIN
test/bytecode_3.7_run/01_for_else_try_else.pyc
Normal file
Binary file not shown.
17
test/simple_source/bug14/01_for_else_try_else.py
Normal file
17
test/simple_source/bug14/01_for_else_try_else.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Adapted from 1.4 anydbm
|
||||||
|
"""This program is self-checking!"""
|
||||||
|
def scan(items):
|
||||||
|
for i in items:
|
||||||
|
try:
|
||||||
|
5 / i
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return 2
|
||||||
|
return i
|
||||||
|
|
||||||
|
assert scan((0, 1)) == 1
|
||||||
|
assert scan((0, 0)) == 2
|
||||||
|
assert scan((3, 2, 1)) == 3
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2016-2019 Rocky Bernstein
|
# Copyright (c) 2016-2020 Rocky Bernstein
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
|
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class Python27Parser(Python2Parser):
|
|||||||
iflaststmtl ::= testexpr c_stmts
|
iflaststmtl ::= testexpr c_stmts
|
||||||
|
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms
|
||||||
bp_come_from ::= POP_BLOCK COME_FROM
|
pb_come_from ::= POP_BLOCK COME_FROM
|
||||||
|
|
||||||
# FIXME: Common with 3.0+
|
# FIXME: Common with 3.0+
|
||||||
jmp_false ::= POP_JUMP_IF_FALSE
|
jmp_false ::= POP_JUMP_IF_FALSE
|
||||||
@@ -164,7 +164,7 @@ class Python27Parser(Python2Parser):
|
|||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
|
||||||
else_suitel COME_FROM
|
else_suitel COME_FROM
|
||||||
|
|
||||||
while1stmt ::= SETUP_LOOP returns bp_come_from
|
while1stmt ::= SETUP_LOOP returns pb_come_from
|
||||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
||||||
|
|
||||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK _come_froms
|
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK _come_froms
|
||||||
|
Reference in New Issue
Block a user