summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/compiler/misc.py9
-rw-r--r--Tools/compiler/compiler/misc.py9
2 files changed, 18 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())
+
diff --git a/Tools/compiler/compiler/misc.py b/Tools/compiler/compiler/misc.py
index 9cbd73f..b4bbe78 100644
--- a/Tools/compiler/compiler/misc.py
+++ b/Tools/compiler/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())
+