diff --git a/NEWS b/NEWS index 3f675882..2e5ff654 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +uncompyle6 2.8.2 2016-08-29 + +- Handle Python 3.6 format string conversions !r, !s, !a +- Start to handle 3.1 bytecode +- Fix some PyPy translation bugs +- We now only handle 3.6.0a3+ since that is incompatible with 3.6 before that + uncompyle6 2.8.1 2016-08-20 - Add Python 2.2 decompilation diff --git a/test/bytecode_2.6/03_raise_from.pyc b/test/bytecode_2.6/03_raise_from.pyc new file mode 100644 index 00000000..97dc8aeb Binary files /dev/null and b/test/bytecode_2.6/03_raise_from.pyc differ diff --git a/test/bytecode_3.4/03_raise_from.pyc b/test/bytecode_3.4/03_raise_from.pyc new file mode 100644 index 00000000..0e56e114 Binary files /dev/null and b/test/bytecode_3.4/03_raise_from.pyc differ diff --git a/test/simple_source/bug26/03_raise_from.py b/test/simple_source/bug26/03_raise_from.py new file mode 100644 index 00000000..ea0bca83 --- /dev/null +++ b/test/simple_source/bug26/03_raise_from.py @@ -0,0 +1,9 @@ +# From 3.4 _pyio.py +# Bug is change in syntax between Python 2 and 3: +# raise_stmt ::= "raise" expression "," expression +# becomes: +# raise_stmt ::= "raise" expression from expression +try: + x = 1 +except AttributeError as err: + raise TypeError("an integer is required"), err diff --git a/test/simple_source/bug33/03_raise_from.py b/test/simple_source/bug33/03_raise_from.py new file mode 100644 index 00000000..e9e881c7 --- /dev/null +++ b/test/simple_source/bug33/03_raise_from.py @@ -0,0 +1,9 @@ +# From 3.4 _pyio.py +# Bug is change in syntax between Python 2 and 3: +# raise_stmt ::= "raise" expression "," expression +# becomes: +# raise_stmt ::= "raise" expression from expression +try: + x = 1 +except AttributeError as err: + raise TypeError("an integer is required") from err diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 4559c523..a1baeaa1 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -278,7 +278,6 @@ TABLE_DIRECT = { 'raise_stmt0': ( '%|raise\n', ), 'raise_stmt1': ( '%|raise %c\n', 0), - 'raise_stmt2': ( '%|raise %c, %c\n', 0, 1), 'raise_stmt3': ( '%|raise %c, %c, %c\n', 0, 1, 2), # 'yield': ( 'yield %c', 0), # 'return_stmt': ( '%|return %c\n', 0), @@ -547,7 +546,16 @@ class SourceWalker(GenericASTTraversal, object): 'DELETE_SLICE+1': ( '%|del %c[%c:]\n', 0, 1 ), 'DELETE_SLICE+2': ( '%|del %c[:%c]\n', 0, 1 ), 'DELETE_SLICE+3': ( '%|del %c[%c:%c]\n', 0, 1, 2 ), - }) + }) + TABLE_DIRECT.update({ + 'raise_stmt2': ( '%|raise %c, %c\n', 0, 1), + }) + else: + # Gotta love Python for its futzing around with syntax like this + TABLE_DIRECT.update({ + 'raise_stmt2': ( '%|raise %c from %c\n', 0, 1), + }) + if 2.0 <= version <= 2.3: TABLE_DIRECT.update({