You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Workaround bug detecting MAKE_FUNCTION docstrings
This commit is contained in:
@@ -895,6 +895,12 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
doc_node = node[0]
|
||||
if doc_node.attr:
|
||||
docstring = doc_node.attr
|
||||
if not isinstance(docstring, str):
|
||||
# FIXME: we have mistakenly tagged something as a doc
|
||||
# string in transform when it isn't one.
|
||||
# The rule in n_mkfunc is pretty flaky.
|
||||
self.prune()
|
||||
return
|
||||
else:
|
||||
docstring = node[0].pattr
|
||||
|
||||
|
@@ -95,10 +95,18 @@ class TreeTransform(GenericASTTraversal, object):
|
||||
|
||||
code = find_code_node(node, code_index).attr
|
||||
|
||||
mkfunc_pattr = node[-1].pattr
|
||||
if isinstance(mkfunc_pattr, tuple):
|
||||
assert len(mkfunc_pattr, 4) and isinstance(mkfunc_pattr, int)
|
||||
is_closure = node[-1].pattr[3] != 0
|
||||
else:
|
||||
# FIXME: This is what we had before. It is hoaky and probably wrong.
|
||||
is_closure = mkfunc_pattr == "closure"
|
||||
|
||||
if (
|
||||
node[-1].pattr != "closure"
|
||||
(not is_closure)
|
||||
and len(code.co_consts) > 0
|
||||
and code.co_consts[0] is not None
|
||||
and isinstance(code.co_consts[0], str)
|
||||
):
|
||||
docstring_node = SyntaxTree(
|
||||
"docstring", [Token("LOAD_STR", has_arg=True, pattr=code.co_consts[0])]
|
||||
|
Reference in New Issue
Block a user