From 260bfd176eda72b6af65653a78bc9658d0863419 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 3 Dec 2017 06:16:29 -0500 Subject: [PATCH] Fix bug in 2.6- except_cond3 --- test/simple_source/bug26/02_except_as.py | 14 ++++++++++---- test/stdlib/runtests.sh | 4 +--- uncompyle6/semantics/pysource.py | 5 +++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/simple_source/bug26/02_except_as.py b/test/simple_source/bug26/02_except_as.py index 1b2e7539..96077828 100644 --- a/test/simple_source/bug26/02_except_as.py +++ b/test/simple_source/bug26/02_except_as.py @@ -1,6 +1,9 @@ # 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: # except KeyError, e # vs 2.6+. @@ -17,9 +20,12 @@ try: value = "foo" -except RuntimeError: + +# Test ensuring parens around (a, b, c) in +# except_cond2 or except_cond3 +except RuntimeError, (a, b, c): # Test: # raise_stmt3 ::= expr expr expr RAISE_VARARGS_3 - raise 1, 2, 3 + raise a, b, c except KeyError, e: raise RuntimeError('foo') diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index d7812991..577ec67a 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -12,10 +12,8 @@ typeset -A SKIP_TESTS case $PYVERSION in 2.4) 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_class.py]=1 # need to fix tryelse + [test_codecs.py]=1 # need to fix tryelse [test_dis.py]=1 # We change line numbers - duh! ) ;; diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index effb6297..8704eae6 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -353,6 +353,7 @@ class SourceWalker(GenericASTTraversal, object): 'testtrue_then': ( 'not %p', (0, 22) ), }) + if 2.4 <= version <= 2.6: TABLE_DIRECT.update({ 'comp_for': ( ' for %c in %c', 3, 1 ), @@ -1901,6 +1902,10 @@ class SourceWalker(GenericASTTraversal, object): node[-2][0].kind = 'unpack_w_parens' self.default(node) + # except_cond3 is only in Python <= 2.6 + n_except_cond3 = n_except_cond2 + + def template_engine(self, entry, startnode): """The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format