Fix bug in 2.6- except_cond3

This commit is contained in:
rocky
2017-12-03 06:16:29 -05:00
parent cfce914889
commit 260bfd176e
3 changed files with 16 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
# From 2.6.9 ConfigParser.py # From 2.6.9 ConfigParser.py
# Note this can only be compiled in Python 2.x # Note: this can only be compiled in Python 2.x
# # Note also name "except_as" is a little bit of
# a misnomer since this is 2.7+ lingo for
# 2.6- syntax which we use here.
# Bug was being able to handle: # Bug was being able to handle:
# except KeyError, e # except KeyError, e
# vs 2.6+. # vs 2.6+.
@@ -17,9 +20,12 @@
try: try:
value = "foo" value = "foo"
except RuntimeError:
# Test ensuring parens around (a, b, c) in
# except_cond2 or except_cond3
except RuntimeError, (a, b, c):
# Test: # Test:
# raise_stmt3 ::= expr expr expr RAISE_VARARGS_3 # raise_stmt3 ::= expr expr expr RAISE_VARARGS_3
raise 1, 2, 3 raise a, b, c
except KeyError, e: except KeyError, e:
raise RuntimeError('foo') raise RuntimeError('foo')

View File

@@ -12,10 +12,8 @@ typeset -A SKIP_TESTS
case $PYVERSION in case $PYVERSION in
2.4) 2.4)
SKIP_TESTS=( [test_binop.py]=1 # need to fix tryelse SKIP_TESTS=( [test_binop.py]=1 # need to fix tryelse
[test_bool.py]=1 # need to fix tryelse
[test_call.py]=1 # need to fix tryelse
[test_cgi.py]=1 # need to fix tryelse [test_cgi.py]=1 # need to fix tryelse
[test_class.py]=1 # need to fix tryelse [test_codecs.py]=1 # need to fix tryelse
[test_dis.py]=1 # We change line numbers - duh! [test_dis.py]=1 # We change line numbers - duh!
) )
;; ;;

View File

@@ -353,6 +353,7 @@ class SourceWalker(GenericASTTraversal, object):
'testtrue_then': ( 'not %p', (0, 22) ), 'testtrue_then': ( 'not %p', (0, 22) ),
}) })
if 2.4 <= version <= 2.6: if 2.4 <= version <= 2.6:
TABLE_DIRECT.update({ TABLE_DIRECT.update({
'comp_for': ( ' for %c in %c', 3, 1 ), 'comp_for': ( ' for %c in %c', 3, 1 ),
@@ -1901,6 +1902,10 @@ class SourceWalker(GenericASTTraversal, object):
node[-2][0].kind = 'unpack_w_parens' node[-2][0].kind = 'unpack_w_parens'
self.default(node) self.default(node)
# except_cond3 is only in Python <= 2.6
n_except_cond3 = n_except_cond2
def template_engine(self, entry, startnode): def template_engine(self, entry, startnode):
"""The format template interpetation engine. See the comment at the """The format template interpetation engine. See the comment at the
beginning of this module for the how we interpret format beginning of this module for the how we interpret format