sys.stdout.write('<screen>' + o.prefix[:i])
p = o.prefix[i:]
+ # Regular expressions for making the doc output consistent,
+ # regardless of reported addresses or Python version.
+
+ # Massage addresses in object repr strings to a constant.
+ address_re = re.compile(r' at 0x[0-9a-fA-F]*\>')
+
+ # Python 2.5 changed the stack trace when the module is read
+ # from standard input from read "... line 7, in ?" to
+ # "... line 7, in <module>".
+ file_re = re.compile(r'^( *File ".*", line \d+, in) \?$', re.M)
+
+ # Python 2.6 made UserList a new-style class, which changes the
+ # AttributeError message generated by our NodeList subclass.
+ nodelist_re = re.compile(r'(AttributeError:) NodeList instance (has no attribute \S+)')
+
for c in o.commandlist:
sys.stdout.write(p + Prompt[o.os])
d = string.replace(c.data, '__ROOT__', '')
elif lines:
content = string.join(lines, '\n' + p)
if content:
- content = re.sub(' at 0x[0-9a-fA-F]*\>', ' at 0x700000>', content)
+ content = address_re.sub(r' at 0x700000>', content)
+ content = file_re.sub(r'\1 <module>', content)
+ content = nodelist_re.sub(r"\1 'NodeList' object \2", content)
content = string.replace(content, '<', '<')
content = string.replace(content, '>', '>')
sys.stdout.write(p + content + '\n')