Merge branch 'master' of github.com:rocky/python-uncompyle6

This commit is contained in:
rocky
2020-01-17 04:44:59 -05:00
6 changed files with 26 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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

View File

@@ -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',

View File

@@ -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+