Merge branch 'master' into grammar-cleanup

This commit is contained in:
rocky
2018-03-25 20:57:51 -04:00
4 changed files with 24 additions and 5 deletions

View File

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

View File

@@ -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 3.6.4 ; do
for VERSION in 3.4.8 3.6.4 ; do
typeset -i rc=0
LOGFILE=/tmp/runtests-$VERSION-$$.log
if ! pyenv local $VERSION ; then

View File

@@ -507,7 +507,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'
@@ -527,7 +527,12 @@ 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] not in
('COME_FROM', 'JUMP_BACK','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

View File

@@ -148,7 +148,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