X Tutup
Skip to content

Commit 05733c6

Browse files
committed
Python 3.5 abc.py bug distilled
1 parent 6765a2e commit 05733c6

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

test/bytecode_3.5/05_abc_class.pyc

525 Bytes
Binary file not shown.

test/bytecode_3.5/06_classbug.pyc

0 Bytes
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Python3.5 bug from abc.py:
2+
# stmt ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST
3+
#
4+
# And this gets ignored.
5+
6+
# Note this is similar to 06_classbug.py but not the same.
7+
# classmethod -> object
8+
9+
class abstractclassmethod(classmethod):
10+
__isabstractmethod__ = True
11+
12+
def __init__(self, callable):
13+
callable.__isabstractmethod__ = True
14+
super().__init__(callable)

test/simple_source/def/06_classbug.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# LOAD_FAST '__locals__'
66
# STORE_LOCALS ''
77

8+
# Note this is similar to 05_abc_class.py but not the same:
9+
# object -> classmethod
10+
811
class abstractclassmethod(object):
912
"""A Python 3.2 STORE_LOCALS bug
1013
"""

uncompyle6/parsers/parse3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,17 @@ def p_35on(self, args):
545545
# this optimization is only used in Python 3.5 and beyond
546546
_ifstmts_jump ::= c_stmts_opt
547547
548-
# Python 3.5 has WITH_CLEANUP_START/FINISH
548+
# Python 3.5+ has WITH_CLEANUP_START/FINISH
549549
withstmt ::= expr SETUP_WITH with_setup suite_stmts_opt
550550
POP_BLOCK LOAD_CONST COME_FROM
551551
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
552552
553553
withasstmt ::= expr SETUP_WITH designator suite_stmts_opt
554554
POP_BLOCK LOAD_CONST COME_FROM
555555
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
556+
557+
# Python 3.5+ classes seem to end with this:
558+
stmt ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST
556559
"""
557560

558561
class Python35onParserSingle(Python35onParser, PythonParserSingle):

0 commit comments

Comments
 (0)
X Tutup