JUMP_BACK and CONTINUE need to be treated more similar...

fixes 148
This commit is contained in:
rocky
2018-01-22 23:08:20 -05:00
parent bd49fcb001
commit 71e7120501
5 changed files with 23 additions and 6 deletions

Binary file not shown.

View 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

View File

@@ -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],

View File

@@ -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

View File

@@ -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.