You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
JUMP_BACK and CONTINUE need to be treated more similar...
fixes 148
This commit is contained in:
BIN
test/bytecode_2.7/02_ifelsetmtl.pyc
Normal file
BIN
test/bytecode_2.7/02_ifelsetmtl.pyc
Normal file
Binary file not shown.
11
test/simple_source/bug27+/02_ifelsetmtl.py
Normal file
11
test/simple_source/bug27+/02_ifelsetmtl.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Issue #148 on 2.7
|
||||||
|
# Bug is in handling CONTINUE like JUMP_BACK
|
||||||
|
# Similar code is probably found in a 2.7 stdlib. mapurl?
|
||||||
|
def reduce_url(url):
|
||||||
|
atoms = []
|
||||||
|
for atom in url:
|
||||||
|
if atom == '.':
|
||||||
|
pass # JUMP_BACK is patched as CONTINUE here
|
||||||
|
elif atom == '..':
|
||||||
|
atoms.push()
|
||||||
|
return atoms
|
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import datetime, os, subprocess, sys, tempfile
|
import datetime, os, subprocess, sys, tempfile
|
||||||
|
|
||||||
from uncompyle6 import verify, IS_PYPY
|
from uncompyle6 import verify, IS_PYPY, PYTHON_VERSION
|
||||||
from xdis.code import iscode
|
from xdis.code import iscode
|
||||||
from uncompyle6.disas import check_object_path
|
from uncompyle6.disas import check_object_path
|
||||||
from uncompyle6.semantics import pysource
|
from uncompyle6.semantics import pysource
|
||||||
@@ -156,10 +156,15 @@ def main(in_base, out_base, files, codes, outfile=None,
|
|||||||
|
|
||||||
# Unbuffer output if possible
|
# Unbuffer output if possible
|
||||||
buffering = -1 if sys.stdout.isatty() else 0
|
buffering = -1 if sys.stdout.isatty() else 0
|
||||||
t = tempfile.NamedTemporaryFile(mode='w+b',
|
if PYTHON_VERSION >= 3.5:
|
||||||
buffering=buffering,
|
t = tempfile.NamedTemporaryFile(mode='w+b',
|
||||||
suffix='.py',
|
buffering=buffering,
|
||||||
prefix=prefix)
|
suffix='.py',
|
||||||
|
prefix=prefix)
|
||||||
|
else:
|
||||||
|
t = tempfile.NamedTemporaryFile(mode='w+b',
|
||||||
|
suffix='.py',
|
||||||
|
prefix=prefix)
|
||||||
current_outfile = t.name
|
current_outfile = t.name
|
||||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering)
|
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering)
|
||||||
tee = subprocess.Popen(["tee", current_outfile],
|
tee = subprocess.Popen(["tee", current_outfile],
|
||||||
|
@@ -131,6 +131,7 @@ class Python27Parser(Python2Parser):
|
|||||||
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
|
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
|
||||||
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
||||||
|
ifelsestmtl ::= testexpr c_stmts_opt CONTINUE else_suitel
|
||||||
|
|
||||||
# Common with 2.6
|
# Common with 2.6
|
||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2015-2017 by Rocky Bernstein
|
# Copyright (c) 2015-2018 by Rocky Bernstein
|
||||||
"""
|
"""
|
||||||
Python 2.7 bytecode ingester.
|
Python 2.7 bytecode ingester.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user