You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Fix bug 3.5+ in handling nested decorators
This commit is contained in:
BIN
test/bytecode_2.6_run/02_decorator.pyc
Normal file
BIN
test/bytecode_2.6_run/02_decorator.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5_run/02_decorator.pyc
Normal file
BIN
test/bytecode_3.5_run/02_decorator.pyc
Normal file
Binary file not shown.
@@ -1,9 +1,34 @@
|
||||
# From python 2.5 make_decorators.py
|
||||
# Bug was in not recognizing @memoize which uses grammra rules
|
||||
# Bug was in not recognizing @memoize which uses grammar rules
|
||||
# using nonterminals mkfuncdeco and mkfuncdeco0
|
||||
|
||||
# This file is RUNNABLE!
|
||||
def memoize(func):
|
||||
pass
|
||||
|
||||
def test_memoize(self):
|
||||
@memoize
|
||||
def double(x):
|
||||
return x * 2
|
||||
|
||||
# Seen in 3.7 test/test_c_locale_coercion.py
|
||||
# Bug was handling multiple decorators in 3.5+
|
||||
# simply because we didn't carry over parser rules over from
|
||||
# earlier versions.
|
||||
|
||||
x = 1
|
||||
def decorator(func):
|
||||
def inc_x():
|
||||
global x
|
||||
x += 1
|
||||
func()
|
||||
return inc_x
|
||||
|
||||
@decorator
|
||||
@decorator
|
||||
def fn():
|
||||
return
|
||||
|
||||
assert x == 1
|
||||
fn()
|
||||
assert x == 3
|
||||
|
@@ -4,3 +4,13 @@ from functools import total_ordering
|
||||
@total_ordering
|
||||
class Frame:
|
||||
pass
|
||||
|
||||
|
||||
# From 3.7 test/test_c_locale_coercion.py
|
||||
# Bug is multiple decorators
|
||||
|
||||
@test
|
||||
@unittest
|
||||
class LocaleCoercionTests():
|
||||
# Test implicit reconfiguration of the environment during CLI startup
|
||||
pass
|
||||
|
@@ -191,7 +191,6 @@ case $PYVERSION in
|
||||
[test_bdb.py]=1 #
|
||||
[test_buffer.py]=1 #
|
||||
[test_builtin.py]=1 #
|
||||
[test_c_locale_coercion.py]=1 # Parse error
|
||||
[test_cmdline.py]=1 # Interactive?
|
||||
[test_codecs-3.7.py]=1
|
||||
[test_collections.py]=1 # Investigate syntax error: self.assertEqual(p, Point(**))
|
||||
|
@@ -835,11 +835,8 @@ class Python3Parser(PythonParser):
|
||||
dict_comp ::= LOAD_DICTCOMP LOAD_STR MAKE_FUNCTION_0 expr
|
||||
GET_ITER CALL_FUNCTION_1
|
||||
classdefdeco1 ::= expr classdefdeco2 CALL_FUNCTION_1
|
||||
classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1
|
||||
"""
|
||||
if self.version < 3.5:
|
||||
rule += """
|
||||
classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1
|
||||
"""
|
||||
self.addRule(rule, nop_func)
|
||||
|
||||
self.custom_classfunc_rule(
|
||||
|
@@ -424,6 +424,7 @@ class Python37BaseParser(PythonParser):
|
||||
dict_comp ::= LOAD_DICTCOMP LOAD_STR MAKE_FUNCTION_0 expr
|
||||
GET_ITER CALL_FUNCTION_1
|
||||
classdefdeco1 ::= expr classdefdeco2 CALL_FUNCTION_1
|
||||
classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1
|
||||
"""
|
||||
self.addRule(rule, nop_func)
|
||||
|
||||
|
Reference in New Issue
Block a user