Author: guido.van.rossum
Date: Tue May  8 21:09:34 2007
New Revision: 55189

Modified:
   python/branches/py3k-struni/Lib/test/test_bytes.py
   python/branches/py3k-struni/Objects/bytesobject.c
Log:
repr(b"\0") should return b"\x00", not the (unusual) b"\0".


Modified: python/branches/py3k-struni/Lib/test/test_bytes.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_bytes.py  (original)
+++ python/branches/py3k-struni/Lib/test/test_bytes.py  Tue May  8 21:09:34 2007
@@ -73,8 +73,9 @@
 
     def test_repr(self):
         self.assertEqual(repr(bytes()), "b''")
-        self.assertEqual(repr(bytes([0])), "b'\\0'")
-        self.assertEqual(repr(bytes([0, 1, 254, 255])), 
"b'\\0\\x01\\xfe\\xff'")
+        self.assertEqual(repr(bytes([0])), "b'\\x00'")
+        self.assertEqual(repr(bytes([0, 1, 254, 255])),
+                         "b'\\x00\\x01\\xfe\\xff'")
         self.assertEqual(repr(bytes('abc')), "b'abc'")
         self.assertEqual(repr(bytes("'")), "b'\\''")
 

Modified: python/branches/py3k-struni/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/bytesobject.c   (original)
+++ python/branches/py3k-struni/Objects/bytesobject.c   Tue May  8 21:09:34 2007
@@ -849,7 +849,7 @@
             else if (c == '\r')
                 *p++ = '\\', *p++ = 'r';
             else if (c == 0)
-                *p++ = '\\', *p++ = '0';
+                *p++ = '\\', *p++ = 'x', *p++ = '0', *p++ = '0';
             else if (c < ' ' || c >= 0x7f) {
                 /* For performance, we don't want to call
                    PyOS_snprintf here (extra layers of
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to