You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Another LOAD_STR/CONST isolation in < 3.0
This commit is contained in:
@@ -128,10 +128,10 @@ PASS = SyntaxTree('stmts',
|
|||||||
[ SyntaxTree('stmt',
|
[ SyntaxTree('stmt',
|
||||||
[ SyntaxTree('pass', [])])])])
|
[ SyntaxTree('pass', [])])])])
|
||||||
|
|
||||||
ASSIGN_DOC_STRING = lambda doc_string: \
|
ASSIGN_DOC_STRING = lambda doc_string, doc_load: \
|
||||||
SyntaxTree('stmt',
|
SyntaxTree('stmt',
|
||||||
[ SyntaxTree('assign',
|
[ SyntaxTree('assign',
|
||||||
[ SyntaxTree('expr', [ Token('LOAD_STR', pattr=doc_string) ]),
|
[ SyntaxTree('expr', [ Token(doc_load, pattr=doc_string) ]),
|
||||||
SyntaxTree('store', [ Token('STORE_NAME', pattr='__doc__')])
|
SyntaxTree('store', [ Token('STORE_NAME', pattr='__doc__')])
|
||||||
])])
|
])])
|
||||||
|
|
||||||
|
@@ -2331,9 +2331,14 @@ def code_deparse(co, out=sys.stdout, version=None, debug_opts=DEFAULT_DEBUG_OPTS
|
|||||||
|
|
||||||
assert not nonlocals
|
assert not nonlocals
|
||||||
|
|
||||||
|
if version >= 3.0:
|
||||||
|
load_op = 'LOAD_STR'
|
||||||
|
else:
|
||||||
|
load_op = 'LOAD_CONST'
|
||||||
|
|
||||||
# convert leading '__doc__ = "..." into doc string
|
# convert leading '__doc__ = "..." into doc string
|
||||||
try:
|
try:
|
||||||
if deparsed.ast[0][0] == ASSIGN_DOC_STRING(co.co_consts[0]):
|
if deparsed.ast[0][0] == ASSIGN_DOC_STRING(co.co_consts[0], load_op):
|
||||||
print_docstring(deparsed, '', co.co_consts[0])
|
print_docstring(deparsed, '', co.co_consts[0])
|
||||||
del deparsed.ast[0]
|
del deparsed.ast[0]
|
||||||
if deparsed.ast[-1] == RETURN_NONE:
|
if deparsed.ast[-1] == RETURN_NONE:
|
||||||
|
Reference in New Issue
Block a user