Kaydet (Commit) 57b93ad5 authored tarafından Guido van Rossum's avatar Guido van Rossum

repr(b"\0") should return b"\x00", not the (unusual) b"\0".

üst e5e80b8c
......@@ -73,8 +73,9 @@ class BytesTest(unittest.TestCase):
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'\\''")
......
......@@ -849,7 +849,7 @@ bytes_repr(PyBytesObject *self)
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment