Pam McA'Nulty added the comment:
- eval expects bytes to have a continuation character and test_str_wrap did an
eval check so I figured test_bytes_wrap should as well:
# repr some bytes:
>>> b = b"\x00\xff" * 5
>>> b
b'\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff'
>>> r = repr(b)
>>> r
"b'\\x00\\xff\\x00\\xff\\x00\\xff\\x00\\xff\\x00\\xff'"
>>> eval(r)
b'\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff'
# hand-wrap it without the continuation character and it fails to eval (stuck
the
>>> s = "b'\\x00\\xff\\x00\\xff\\x00'\nb'\\xff\\x00\\xff\\x00\\xff'"
>>> print(s)
b'\x00\xff\x00\xff\x00'
b'\xff\x00\xff\x00\xff'
>>> eval(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2
b'\xff\x00\xff\x00\xff'
^
SyntaxError: invalid syntax
# stick the continuation character in, and it evals properly
>>> s = s.replace("\n", "\\\n")
>>> print(s)
b'\x00\xff\x00\xff\x00'\
b'\xff\x00\xff\x00\xff'
>>> eval(s)
b'\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff'
- I agree about the len v _len, but figured this wasn't all that foolish a
consistency issue (i.e. the rest of pprint.py used _len)
- I also wanted to refactor _str_parts and _bytes_parts, but couldn't decide on
the best course. I was favoring a helper function to run the common loop since
the two "if issubclass..." calls were so different and parameterizing the
differences felt like it would obfuscate things too much.
- I also agree on the doc. I figured I'd see if there weren't any hidden
surprises with the patch before I worked on better doc.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com