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 199096 71894fdee8e0553aeaa1fcfe77a3fdd935099e15
parent 199095 61606b2f3d37e7f3cdd037002899b5127d76ddc3
child 199097 4c247bfe9d75c38ff58c3166281e1fd53d5b1678
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, test-only
bugs975550
milestone31.0a2
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):