You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
parens around consts when taking attr again
This commit is contained in:
Binary file not shown.
BIN
test/bytecode_3.7_run/01_class.pyc
Normal file
BIN
test/bytecode_3.7_run/01_class.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.8_run/01_class.pyc
Normal file
BIN
test/bytecode_3.8_run/01_class.pyc
Normal file
Binary file not shown.
@@ -8,8 +8,19 @@
|
||||
# classdef ::= LOAD_CONST expr mkfunc CALL_FUNCTION_0 BUILD_CLASS store
|
||||
# mkfunc ::= LOAD_CONST MAKE_FUNCTION_0
|
||||
|
||||
# RUNNABLE!
|
||||
class A:
|
||||
pass
|
||||
|
||||
class B(Exception):
|
||||
pass
|
||||
|
||||
# From 3.x test_descr.py
|
||||
class MyInt(int):
|
||||
class MyInt(int):
|
||||
__slots__ = ()
|
||||
try:
|
||||
(1).__class__ = MyInt
|
||||
assert False, "builtin types don't support __class__ assignment."
|
||||
except TypeError:
|
||||
pass
|
||||
|
@@ -268,6 +268,10 @@ TABLE_DIRECT = {
|
||||
'attribute_w_parens': ( '(%c).%[1]{pattr}',
|
||||
(0, 'expr')),
|
||||
|
||||
# This nonterminal we create on the fly in semantic routines
|
||||
'store_w_parens': ( '(%c).%[1]{pattr}',
|
||||
(0, 'expr')),
|
||||
|
||||
'unpack_list': ( '[%C]',
|
||||
(1, maxint, ', ') ),
|
||||
'build_tuple2': ( '%P',
|
||||
|
@@ -1889,6 +1889,17 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
|
||||
n_set = n_tuple = n_build_set = n_list
|
||||
|
||||
def n_store(self, node):
|
||||
expr = node[0]
|
||||
if expr == "expr" and expr[0] == "LOAD_CONST" and node[1] == "STORE_ATTR":
|
||||
# FIXME: I didn't record which constants parenthesis is
|
||||
# necessary. However, I suspect that we could further
|
||||
# refine this by looking at operator precedence and
|
||||
# eval'ing the constant value (pattr) and comparing with
|
||||
# the type of the constant.
|
||||
node.kind = "store_w_parens"
|
||||
self.default(node)
|
||||
|
||||
def n_unpack(self, node):
|
||||
if node[0].kind.startswith("UNPACK_EX"):
|
||||
# Python 3+
|
||||
|
Reference in New Issue
Block a user