Misc changes

Back off of some validation tests for now.
This commit is contained in:
rocky
2016-05-12 11:22:00 -04:00
parent 6f6f1db576
commit 5babde61c4
7 changed files with 17 additions and 19 deletions

Binary file not shown.

View File

@@ -1,5 +1,3 @@
if __name__:
for i in (1,2):
x = 3
pass
pass

View File

@@ -5,6 +5,7 @@ from uncompyle6 import verify, PYTHON_VERSION
from uncompyle6.code import iscode
from uncompyle6.disas import check_object_path
from uncompyle6.semantics import pysource
from uncompyle6.parser import ParserError
from uncompyle6.load import load_module
@@ -114,8 +115,8 @@ def main(in_base, out_base, files, codes, outfile=None,
try:
uncompyle_file(infile, outstream, showasm, showast, showgrammar)
tot_files += 1
except (ValueError, SyntaxError) as e:
sys.stderr.write("\n# %s" % e)
except (ValueError, SyntaxError, ParserError) as e:
sys.stderr.write("\n# file %s\n# %s" % (infile, e))
failed_files += 1
except KeyboardInterrupt:
if outfile:

View File

@@ -143,7 +143,7 @@ class Python3Parser(PythonParser):
return_stmts ::= return_stmt
return_stmts ::= _stmts return_stmt
return_if_stmts ::= return_if_stmt
return_if_stmts ::= return_if_stmt come_from_opt
return_if_stmts ::= _stmts return_if_stmt
return_if_stmt ::= ret_expr RETURN_VALUE
@@ -333,17 +333,25 @@ class Python3Parser(PythonParser):
'''
def p_misc(self, args):
"""
_jump ::= NOP
try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY NOP COME_FROM
"""
def p_stmt3(self, args):
"""
stmt ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST
stmt ::= whileTruestmt
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite _come_from
# Python 3.5 may have POP_BLOCK
forstmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK NOP _come_from
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK _come_from
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP _come_from
# Python < 3.5 no POP BLOCK
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK \e__come_from
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK _come_from
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP _come_from
"""
def p_genexpr3(self, args):

View File

@@ -39,6 +39,7 @@ import uncompyle6.scanner as scan
class Scanner3(scan.Scanner):
def __init__(self, version):
self.version = version
scan.Scanner.__init__(self, version)
def disassemble_generic(self, co, classname=None, code_objects={}):
@@ -215,17 +216,6 @@ class Scanner3(scan.Scanner):
op_name = 'JUMP_BACK'
pass
pass
elif target > offset:
# Python 3.5 will use JUMP_FORWARD where 3.2 may
# use JUMP_ABSOLUTE. Which direction we move
# simplifies grammar rules working with both 3.2
# and 3.5. So optimize the way Python 3.5 does it.
#
# We may however want to consider whether we do
# this in 3.5 or not.
op_name = 'JUMP_FORWARD'
oparg -= offset
pass
pass
elif op_name == 'JUMP_FORWARD':
# Python 3.5 will optimize out a JUMP_FORWARD to the
@@ -235,7 +225,8 @@ class Scanner3(scan.Scanner):
#
# We may however want to consider whether we do
# this in 3.5 or not.
if oparg == 0:
if oparg == 0 and self.version != 3.4:
tokens.append(Token('NOP', oparg, pattr, offset, linestart))
continue
elif op_name == 'LOAD_GLOBAL':
if offset in self.load_asserts: