You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
__modname__ and __qualname__ detection...
since grammar has simplified. May still need work for Python < 3.0
This commit is contained in:
@@ -142,13 +142,12 @@ ASSIGN_DOC_STRING = lambda doc_string, doc_load: \
|
|||||||
SyntaxTree("store", [ Token("STORE_NAME", pattr="__doc__")])
|
SyntaxTree("store", [ Token("STORE_NAME", pattr="__doc__")])
|
||||||
])])
|
])])
|
||||||
|
|
||||||
NAME_MODULE = SyntaxTree("sstmt",
|
NAME_MODULE = SyntaxTree('assign',
|
||||||
[ SyntaxTree("assign",
|
[ SyntaxTree('expr',
|
||||||
[ SyntaxTree("expr",
|
[Token('LOAD_NAME', pattr='__name__', offset=0, has_arg=True)]),
|
||||||
[Token("LOAD_NAME", pattr="__name__", offset=0, has_arg=True)]),
|
SyntaxTree('store',
|
||||||
SyntaxTree("store",
|
[ Token('STORE_NAME', pattr='__module__', offset=3, has_arg=True)])
|
||||||
[ Token("STORE_NAME", pattr="__module__", offset=3, has_arg=True)])
|
])
|
||||||
])])
|
|
||||||
|
|
||||||
# God intended \t, but Python has decided to use 4 spaces.
|
# God intended \t, but Python has decided to use 4 spaces.
|
||||||
# If you want real tabs, use Go.
|
# If you want real tabs, use Go.
|
||||||
|
@@ -2310,16 +2310,17 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
# FIXME: is this right now that we've redone the grammar?
|
||||||
have_qualname = ast[0][0] == QUAL_NAME
|
have_qualname = ast[0][0] == QUAL_NAME
|
||||||
else:
|
else:
|
||||||
# Python 3.4+ has constants like 'cmp_to_key.<locals>.K'
|
# Python 3.4+ has constants like 'cmp_to_key.<locals>.K'
|
||||||
# which are not simple classes like the < 3 case.
|
# which are not simple classes like the < 3 case.
|
||||||
try:
|
try:
|
||||||
if (
|
if (
|
||||||
first_stmt[0] == "assign"
|
first_stmt == "assign"
|
||||||
and first_stmt[0][0][0] == "LOAD_STR"
|
and first_stmt[0][0] == "LOAD_STR"
|
||||||
and first_stmt[0][1] == "store"
|
and first_stmt[1] == "store"
|
||||||
and first_stmt[0][1][0] == Token("STORE_NAME", pattr="__qualname__")
|
and first_stmt[1][0] == Token("STORE_NAME", pattr="__qualname__")
|
||||||
):
|
):
|
||||||
have_qualname = True
|
have_qualname = True
|
||||||
except:
|
except:
|
||||||
|
Reference in New Issue
Block a user