You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
Merge branch 'master' into python-2.4
This commit is contained in:
1
test/.gitignore
vendored
Normal file
1
test/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/nohup.out
|
@@ -1,5 +1,5 @@
|
||||
# From 2.7 test_argparse.py
|
||||
# Bug was turnning assert into an "or raise" statement
|
||||
# Bug was turning assert into an "or raise" statement
|
||||
def __call__(arg, dest):
|
||||
try:
|
||||
assert arg == 'spam', 'dest: %s' % dest
|
||||
@@ -15,3 +15,17 @@ def refactor_doctest(clipped, new):
|
||||
if not new:
|
||||
new += u"\n"
|
||||
return
|
||||
|
||||
# From 2.7.14 test_hashlib.py
|
||||
# The bug was turning assert into an "if"
|
||||
# statement which isn't wrong, but we got the
|
||||
# range of the if incorrect. When we have
|
||||
# better control flow analysis we can revisit.
|
||||
def test_threaded_hashing():
|
||||
for threadnum in xrange(1):
|
||||
result = 1
|
||||
assert result > 0
|
||||
result = 2
|
||||
return result
|
||||
|
||||
assert test_threaded_hashing() == 2
|
||||
|
@@ -2,7 +2,7 @@
|
||||
USER=${USER:-rocky}
|
||||
EMAIL=${EMAIL:-rb@dustyfeet.com}
|
||||
SUBJECT_PREFIX="stdlib unit testing for"
|
||||
for VERSION in 2.7.14 2.6.9 ; do
|
||||
for VERSION in 2.7.14 2.6.9 3.6.4 ; do
|
||||
typeset -i rc=0
|
||||
LOGFILE=/tmp/runtests-$VERSION-$$.log
|
||||
if ! pyenv local $VERSION ; then
|
||||
|
@@ -328,11 +328,9 @@ class Python2Parser(PythonParser):
|
||||
'dict_comp_func', 0, customize)
|
||||
|
||||
else:
|
||||
kvlist_n = "kvlist_%s" % token.attr
|
||||
self.add_unique_rules([
|
||||
(kvlist_n + " ::=" + ' kv3' * token.attr),
|
||||
"dict ::= %s %s" % (opname, kvlist_n)
|
||||
], customize)
|
||||
kvlist_n = ' kv3' * token.attr
|
||||
rule = "dict ::= %s%s" % (opname, kvlist_n)
|
||||
self.addRule(rule, nop_func)
|
||||
continue
|
||||
elif opname_base == 'BUILD_SLICE':
|
||||
slice_num = token.attr
|
||||
@@ -518,7 +516,7 @@ class Python2Parser(PythonParser):
|
||||
self.addRule(rule, nop_func)
|
||||
pass
|
||||
|
||||
self.check_reduce['aug_assign1'] = 'AST'
|
||||
self.check_reduce['raise_stmt1'] = 'tokens'
|
||||
self.check_reduce['aug_assign2'] = 'AST'
|
||||
self.check_reduce['or'] = 'AST'
|
||||
# self.check_reduce['_stmts'] = 'AST'
|
||||
@@ -538,7 +536,11 @@ class Python2Parser(PythonParser):
|
||||
|
||||
if lhs in ('aug_assign1', 'aug_assign2') and ast[0] and ast[0][0] in ('and', 'or'):
|
||||
return True
|
||||
if rule == ('or', ('expr', 'jmp_true', 'expr', '\\e_come_from_opt')):
|
||||
elif lhs in ('raise_stmt1',):
|
||||
# We will assme 'LOAD_ASSERT' will be handled by an assert grammar rule
|
||||
return (tokens[first] == 'LOAD_ASSERT' and
|
||||
(last >= len(tokens) or tokens[last] != 'JUMP_FORWARD'))
|
||||
elif rule == ('or', ('expr', 'jmp_true', 'expr', '\\e_come_from_opt')):
|
||||
expr2 = ast[2]
|
||||
return expr2 == 'expr' and expr2[0] == 'LOAD_ASSERT'
|
||||
return False
|
||||
|
@@ -647,6 +647,8 @@ class Python3Parser(PythonParser):
|
||||
elif self.version >= 3.5:
|
||||
if opname != 'BUILD_MAP_WITH_CALL':
|
||||
if opname == 'BUILD_MAP_UNPACK':
|
||||
# FIXME: start here
|
||||
# rule = "%s ::= %s %s" % (kvlist_n, 'expr ' * (token.attr*2), opname)
|
||||
rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
rule = 'dict_entry ::= ' + 'expr ' * (token.attr*2)
|
||||
|
@@ -152,7 +152,7 @@ class Scanner2(Scanner):
|
||||
# raise AssertionError
|
||||
# and
|
||||
# assert ...
|
||||
# Below we use the heuristic that it is preceded by a POP_JUMP.
|
||||
# Below we use the heuristic that an "sssert" is preceded by a POP_JUMP.
|
||||
# however we could also use followed by RAISE_VARARGS
|
||||
# or for PyPy there may be a JUMP_IF_NOT_DEBUG before.
|
||||
# FIXME: remove uses of PJIF, and PJIT
|
||||
|
@@ -1705,10 +1705,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
kv_node = node[0]
|
||||
l = list(kv_node)
|
||||
length = len(l)
|
||||
|
||||
# FIXME: Parser-speed improved grammars will have BUILD_MAP
|
||||
# at the end. So in the future when everything is
|
||||
# complete, we can do an "assert" instead of "if".
|
||||
if kv_node[-1].kind.startswith("BUILD_MAP"):
|
||||
length -= 1
|
||||
i = 0
|
||||
@@ -1784,13 +1780,20 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
pass
|
||||
pass
|
||||
else:
|
||||
# Python 2 style kvlist
|
||||
assert node[-1].kind.startswith('kvlist')
|
||||
kv_node = node[-1] # goto kvlist
|
||||
# Python 2 style kvlist. Find beginning of kvlist.
|
||||
if node[0].kind.startswith("BUILD_MAP"):
|
||||
if len(node) > 1 and node[1].kind in ('kvlist', 'kvlist_n'):
|
||||
kv_node = node[1]
|
||||
else:
|
||||
kv_node = node[1:]
|
||||
else:
|
||||
assert node[-1].kind.startswith('kvlist')
|
||||
kv_node = node[-1]
|
||||
|
||||
first_time = True
|
||||
for kv in kv_node:
|
||||
assert kv in ('kv', 'kv2', 'kv3')
|
||||
|
||||
# kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR
|
||||
# kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR
|
||||
# kv3 ::= expr expr STORE_MAP
|
||||
|
Reference in New Issue
Block a user