Fixed bug in pysource / fragments where the use of deparse_code from fragments could break subsequent calls to deparse_code from pysource due to amending to the global TABLE_DIRECT.

This commit is contained in:
Daniel Bradburn
2016-05-25 20:26:13 +02:00
parent 79593d6ef1
commit ebee84228b
2 changed files with 16 additions and 5 deletions

View File

@@ -1526,7 +1526,7 @@ class SourceWalker(GenericASTTraversal, object):
self.write(fmt[i:])
def default(self, node):
mapping = MAP.get(node, MAP_DIRECT)
mapping = self._get_mapping(node)
table = mapping[0]
key = node
@@ -1861,6 +1861,11 @@ class SourceWalker(GenericASTTraversal, object):
return ast
@classmethod
def _get_mapping(cls, node):
return MAP.get(node, MAP_DIRECT)
def deparse_code(version, co, out=sys.stdout, showasm=False, showast=False,
showgrammar=False, code_objects={}, compile_mode='exec'):
"""