You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Document/correct hide_internal and store_locals
This commit is contained in:
BIN
test/bytecode_3.2/05_store_locals.pyc
Normal file
BIN
test/bytecode_3.2/05_store_locals.pyc
Normal file
Binary file not shown.
@@ -569,7 +569,7 @@ class Python3Parser(PythonParser):
|
||||
class Python32Parser(Python3Parser):
|
||||
def p_32(self, args):
|
||||
"""
|
||||
# Store locals is only in Python 3.2 and 3.3
|
||||
# Store locals is only in Python 3.0 to 3.3
|
||||
stmt ::= store_locals
|
||||
store_locals ::= LOAD_FAST STORE_LOCALS
|
||||
"""
|
||||
@@ -577,7 +577,7 @@ class Python32Parser(Python3Parser):
|
||||
class Python33Parser(Python3Parser):
|
||||
def p_33(self, args):
|
||||
"""
|
||||
# Store locals is only in Python 3.2 and 3.3
|
||||
# Store locals is only in Python 3.0 to 3.3
|
||||
stmt ::= store_locals
|
||||
store_locals ::= LOAD_FAST STORE_LOCALS
|
||||
|
||||
|
@@ -137,7 +137,16 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
self.currentclass = None
|
||||
self.classes = []
|
||||
self.pending_newlines = 0
|
||||
|
||||
# hide_internal suppresses displaying the additional instructions that sometimes
|
||||
# exist in code but but were not written in the source code.
|
||||
# An example is:
|
||||
# __module__ = __name__
|
||||
# If showing source code we generally don't want to show this. However in fragment
|
||||
# deparsing we generally do need to see these instructions since we may be stopped
|
||||
# at one. So here we do not want to suppress showing such instructions.
|
||||
self.hide_internal = False
|
||||
|
||||
self.name = None
|
||||
|
||||
self.offsets = {}
|
||||
@@ -654,6 +663,12 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
|
||||
# find innermost node
|
||||
if_node = None
|
||||
comp_for = None
|
||||
comp_designator = None
|
||||
if n == 'comp_iter':
|
||||
comp_for = n
|
||||
comp_designator = ast[3]
|
||||
|
||||
while n in ('list_iter', 'comp_iter'):
|
||||
n = n[0] # recurse one step
|
||||
if n == 'list_for':
|
||||
@@ -668,8 +683,9 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
pass
|
||||
pass
|
||||
|
||||
# Python 2.7+ starts including set_comp_body
|
||||
# Python 3.5+ starts including setcomp_func
|
||||
assert n.type in ('lc_body', 'comp_body', 'setcomp_func'), ast
|
||||
assert n.type in ('lc_body', 'comp_body', 'setcomp_func', 'set_comp_body'), ast
|
||||
assert designator, "Couldn't find designator in list/set comprehension"
|
||||
|
||||
old_name = self.name
|
||||
@@ -686,7 +702,10 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
self.preorder(node[-3])
|
||||
fin = len(self.f.getvalue())
|
||||
self.set_pos_info(node[-3], start, fin, old_name)
|
||||
if if_node:
|
||||
|
||||
if comp_designator:
|
||||
self.preorder(comp_for)
|
||||
elif if_node:
|
||||
self.write(' if ')
|
||||
self.preorder(if_node)
|
||||
self.prec = p
|
||||
|
@@ -545,6 +545,11 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.currentclass = None
|
||||
self.classes = []
|
||||
self.pending_newlines = 0
|
||||
|
||||
# hide_internal suppresses displaying the additional instructions that sometimes
|
||||
# exist in code but but were not written in the source code.
|
||||
# An example is:
|
||||
# __module__ = __name__
|
||||
self.hide_internal = True
|
||||
self.name = None
|
||||
self.version = version
|
||||
|
Reference in New Issue
Block a user