From de556e211a2f3bb5e979935cf37ca7bfa755b2eb Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 14 Jan 2010 14:43:51 +0000 Subject: [PATCH] Massage the output from examples for consistency with Python 2.6. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4616 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- bin/sconsoutput.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/sconsoutput.py b/bin/sconsoutput.py index 2c6e4d5f..e2237c55 100644 --- a/bin/sconsoutput.py +++ b/bin/sconsoutput.py @@ -739,6 +739,21 @@ class MySGML(sgmllib.SGMLParser): sys.stdout.write('' + 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 ". + 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__', '') @@ -753,7 +768,9 @@ class MySGML(sgmllib.SGMLParser): 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 ', 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') -- 2.26.2