You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Remove Python2 buitin "print" from Python3's grammr. Start class tests
This commit is contained in:
2
test/simple_source/def/01_class.py
Normal file
2
test/simple_source/def/01_class.py
Normal file
@@ -0,0 +1,2 @@
|
||||
class A:
|
||||
pass
|
33
test/simple_source/def/10_class.py
Normal file
33
test/simple_source/def/10_class.py
Normal file
@@ -0,0 +1,33 @@
|
||||
class A:
|
||||
|
||||
class A1:
|
||||
def __init__(self):
|
||||
self.a1 = True
|
||||
|
||||
def foo(self):
|
||||
self.b = True
|
||||
|
||||
def __init__(self):
|
||||
self.a = True
|
||||
|
||||
def foo(self):
|
||||
self.fooed = True
|
||||
|
||||
|
||||
class B:
|
||||
def __init__(self):
|
||||
self.bed = True
|
||||
|
||||
def bar(self):
|
||||
self.barred = True
|
||||
|
||||
|
||||
class C(A,B):
|
||||
def foobar(self):
|
||||
self.foobared = True
|
||||
|
||||
|
||||
c = C()
|
||||
c.foo()
|
||||
c.bar()
|
||||
c.foobar()
|
@@ -92,6 +92,12 @@ def_op('STORE_LOCALS', 69)
|
||||
def_op('PRINT_EXPR', 70)
|
||||
def_op('LOAD_BUILD_CLASS', 71)
|
||||
|
||||
# Python3 drops/changes:
|
||||
# def_op('PRINT_ITEM', 71)
|
||||
# def_op('PRINT_NEWLINE', 72)
|
||||
# def_op('PRINT_ITEM_TO', 73)
|
||||
# def_op('PRINT_NEWLINE_TO', 74)
|
||||
|
||||
def_op('INPLACE_LSHIFT', 75)
|
||||
def_op('INPLACE_RSHIFT', 76)
|
||||
def_op('INPLACE_AND', 77)
|
||||
|
@@ -100,13 +100,19 @@ def_op('BINARY_OR', 66)
|
||||
def_op('INPLACE_POWER', 67)
|
||||
def_op('GET_ITER', 68)
|
||||
|
||||
## FIXME: no code generates this
|
||||
# FIXME: no code generates this
|
||||
def_op('STORE_LOCALS', 69)
|
||||
|
||||
def_op('PRINT_EXPR', 70)
|
||||
def_op('LOAD_BUILD_CLASS', 71)
|
||||
def_op('YIELD_FROM', 72)
|
||||
|
||||
# Python3 drops/changes:
|
||||
# def_op('PRINT_ITEM', 71)
|
||||
# def_op('PRINT_NEWLINE', 72)
|
||||
# def_op('PRINT_ITEM_TO', 73)
|
||||
# def_op('PRINT_NEWLINE_TO', 74)
|
||||
|
||||
def_op('INPLACE_LSHIFT', 75)
|
||||
def_op('INPLACE_RSHIFT', 76)
|
||||
def_op('INPLACE_AND', 77)
|
||||
|
@@ -164,34 +164,35 @@ class Python3Parser(PythonParser):
|
||||
assign3 ::= expr expr expr ROT_THREE ROT_TWO designator designator designator
|
||||
'''
|
||||
|
||||
def p_print(self, args):
|
||||
'''
|
||||
stmt ::= print_items_stmt
|
||||
stmt ::= print_nl
|
||||
stmt ::= print_items_nl_stmt
|
||||
# Python3 doesn't have a built-in print.
|
||||
# def p_print(self, args):
|
||||
# '''
|
||||
# stmt ::= print_items_stmt
|
||||
# stmt ::= print_nl
|
||||
# stmt ::= print_items_nl_stmt
|
||||
|
||||
print_items_stmt ::= expr PRINT_ITEM print_items_opt
|
||||
print_items_nl_stmt ::= expr PRINT_ITEM print_items_opt PRINT_NEWLINE_CONT
|
||||
print_items_opt ::= print_items
|
||||
print_items_opt ::=
|
||||
print_items ::= print_items print_item
|
||||
print_items ::= print_item
|
||||
print_item ::= expr PRINT_ITEM_CONT
|
||||
print_nl ::= PRINT_NEWLINE
|
||||
'''
|
||||
# print_items_stmt ::= expr PRINT_ITEM print_items_opt
|
||||
# print_items_nl_stmt ::= expr PRINT_ITEM print_items_opt PRINT_NEWLINE_CONT
|
||||
# print_items_opt ::= print_items
|
||||
# print_items_opt ::=
|
||||
# print_items ::= print_items print_item
|
||||
# print_items ::= print_item
|
||||
# print_item ::= expr PRINT_ITEM_CONT
|
||||
# print_nl ::= PRINT_NEWLINE
|
||||
# '''
|
||||
|
||||
def p_print_to(self, args):
|
||||
'''
|
||||
stmt ::= print_to
|
||||
stmt ::= print_to_nl
|
||||
stmt ::= print_nl_to
|
||||
print_to ::= expr print_to_items POP_TOP
|
||||
print_to_nl ::= expr print_to_items PRINT_NEWLINE_TO
|
||||
print_nl_to ::= expr PRINT_NEWLINE_TO
|
||||
print_to_items ::= print_to_items print_to_item
|
||||
print_to_items ::= print_to_item
|
||||
print_to_item ::= DUP_TOP expr ROT_TWO PRINT_ITEM_TO
|
||||
'''
|
||||
# def p_print_to(self, args):
|
||||
# '''
|
||||
# stmt ::= print_to
|
||||
# stmt ::= print_to_nl
|
||||
# stmt ::= print_nl_to
|
||||
# print_to ::= expr print_to_items POP_TOP
|
||||
# print_to_nl ::= expr print_to_items PRINT_NEWLINE_TO
|
||||
# print_nl_to ::= expr PRINT_NEWLINE_TO
|
||||
# print_to_items ::= print_to_items print_to_item
|
||||
# print_to_items ::= print_to_item
|
||||
# print_to_item ::= DUP_TOP expr ROT_TWO PRINT_ITEM_TO
|
||||
# '''
|
||||
|
||||
def p_import20(self, args):
|
||||
'''
|
||||
|
Reference in New Issue
Block a user