You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Handle Python 2 vs 3 raise syntax change
raise_stmt ::= "raise" expression "," expression becomes: raise_stmt ::= "raise" expression from expression raise expr, expr -> raise
This commit is contained in:
7
NEWS
7
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
|
||||
|
BIN
test/bytecode_2.6/03_raise_from.pyc
Normal file
BIN
test/bytecode_2.6/03_raise_from.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.4/03_raise_from.pyc
Normal file
BIN
test/bytecode_3.4/03_raise_from.pyc
Normal file
Binary file not shown.
9
test/simple_source/bug26/03_raise_from.py
Normal file
9
test/simple_source/bug26/03_raise_from.py
Normal file
@@ -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
|
9
test/simple_source/bug33/03_raise_from.py
Normal file
9
test/simple_source/bug33/03_raise_from.py
Normal file
@@ -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
|
@@ -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({
|
||||
|
Reference in New Issue
Block a user