summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/misc.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-09-17 18:02:21 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-09-17 18:02:21 (GMT)
commit09392b77a4d8be766e394177a466d51c2a64480f (patch)
treec6e5c05ddc75b312f14f8703b004b94b907b7256 /Lib/compiler/misc.py
parentb329b7134c15e6d1baafb5597e85de514b1eb588 (diff)
downloadcpython-09392b77a4d8be766e394177a466d51c2a64480f.zip
cpython-09392b77a4d8be766e394177a466d51c2a64480f.tar.gz
cpython-09392b77a4d8be766e394177a466d51c2a64480f.tar.bz2
Add utility to set filename attribute on all nodes
Diffstat (limited to 'Lib/compiler/misc.py')
-rw-r--r--Lib/compiler/misc.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py
index 9cbd73f..b4bbe78 100644
--- a/Lib/compiler/misc.py
+++ b/Lib/compiler/misc.py
@@ -64,3 +64,12 @@ def mangle(name, klass):
klass = klass[:MANGLE_LEN-tlen]
return "_%s%s" % (klass, name)
+
+def set_filename(filename, tree):
+ """Set the filename attribute to filename on every node in tree"""
+ worklist = [tree]
+ while worklist:
+ node = worklist.pop(0)
+ node.filename = filename
+ worklist.extend(node.getChildNodes())
+