You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
3.6+ try/finally bugs
Another day another 3.6 bug fix attempted
This commit is contained in:
BIN
test/bytecode_3.6/04_try_finally.pyc
Normal file
BIN
test/bytecode_3.6/04_try_finally.pyc
Normal file
Binary file not shown.
20
test/simple_source/bug36/04_try_finally.py
Normal file
20
test/simple_source/bug36/04_try_finally.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# From 3.6 _pyio.py
|
||||
# Bug was in "return" not having "COME_FROM"
|
||||
# and in 1st try/finally no END_FINALLY (which really
|
||||
# hooks into the control-flow analysis).
|
||||
# The 2nd try/finally has an END_FINALLY although still
|
||||
# no "COME_FROM".
|
||||
|
||||
def getvalue(self):
|
||||
try:
|
||||
return 3
|
||||
finally:
|
||||
return 1
|
||||
|
||||
|
||||
def getvalue1(self):
|
||||
try:
|
||||
return 4
|
||||
finally:
|
||||
pass
|
||||
return 2
|
@@ -30,6 +30,8 @@ class Python36Parser(Python35Parser):
|
||||
|
||||
def p_36misc(self, args):
|
||||
"""
|
||||
sstmt ::= sstmt RETURN_LAST
|
||||
|
||||
# 3.6 redoes how return_closure works
|
||||
return_closure ::= LOAD_CLOSURE DUP_TOP STORE_NAME RETURN_VALUE RETURN_LAST
|
||||
|
||||
@@ -64,7 +66,14 @@ class Python36Parser(Python35Parser):
|
||||
except_handler36 ::= COME_FROM_EXCEPT except_stmts END_FINALLY
|
||||
|
||||
stmt ::= try_except36
|
||||
try_except36 ::= SETUP_EXCEPT returns except_handler36 opt_come_from_except
|
||||
try_except36 ::= SETUP_EXCEPT returns except_handler36
|
||||
opt_come_from_except
|
||||
|
||||
stmt ::= tryfinally36
|
||||
tryfinally36 ::= SETUP_FINALLY returns
|
||||
COME_FROM_FINALLY suite_stmts
|
||||
tryfinally36 ::= SETUP_FINALLY returns
|
||||
COME_FROM_FINALLY suite_stmts_opt END_FINALLY
|
||||
"""
|
||||
|
||||
def customize_grammar_rules(self, tokens, customize):
|
||||
|
@@ -1,4 +1,17 @@
|
||||
# Copyright (c) 2018 by Rocky Bernstein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Isolate Python version-specific semantic actions here.
|
||||
"""
|
||||
@@ -341,6 +354,8 @@ def customize_for_version(self, is_pypy, version):
|
||||
#######################
|
||||
|
||||
TABLE_DIRECT.update({
|
||||
'tryfinally36': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n',
|
||||
(1, 'returns'), 3 ),
|
||||
'fstring_expr': ( "{%c%{conversion}}", 0),
|
||||
'fstring_single': ( "f'{%c%{conversion}}'", 0),
|
||||
'fstring_multi': ( "f'%c'", 0),
|
||||
|
Reference in New Issue
Block a user