Bug 975550 Handle python 2.6 when preventing invalid utf-8 being writting to test files. r=ted,a=test-only
authorMark Banner <standard8@mozilla.com>
Tue, 06 May 2014 20:11:30 +0100
changeset 192222 04c5fcc3831b
parent 192221 68d24bc3a93d
child 192223 1fc8f2d7a261
child 192229 38ccbfe4f7aa
child 192235 e3d33f95a066
child 192237 085e487a0049
push id3531
push usermbanner@mozilla.com
push date2014-05-08 08:58 +0000
Treeherderresults
reviewersted, test-only
bugs975550
milestone30.0
Bug 975550 Handle python 2.6 when preventing invalid utf-8 being writting to test files. r=ted,a=test-only
testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -77,17 +77,17 @@ import mozinfo
 # TODO: perhaps this should be in a more generally shared location?
 # This regex matches all of the C0 and C1 control characters
 # (U+0000 through U+001F; U+007F; U+0080 through U+009F),
 # except TAB (U+0009), CR (U+000D), LF (U+000A) and backslash (U+005C).
 # A raw string is deliberately not used.
 _cleanup_encoding_re = re.compile(u'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\\\\]')
 def _cleanup_encoding_repl(m):
     c = m.group(0)
-    return '\\\\' if c == '\\' else '\\x{:02X}'.format(ord(c))
+    return '\\\\' if c == '\\' else '\\x{0:02X}'.format(ord(c))
 def cleanup_encoding(s):
     """S is either a byte or unicode string.  Either way it may
        contain control characters, unpaired surrogates, reserved code
        points, etc.  If it is a byte string, it is assumed to be
        UTF-8, but it may not be *correct* UTF-8.  Produce a byte
        string that can safely be dumped into a (generally UTF-8-coded)
        logfile."""
     if not isinstance(s, unicode):