[issue17530] pprint could use line continuation for long bytes literals

2015-03-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ _

[issue17530] pprint could use line continuation for long bytes literals

2015-03-24 Thread Roundup Robot
Roundup Robot added the comment: New changeset 976de10bf731 by Serhiy Storchaka in branch 'default': Issue #17530: pprint now wraps long bytes objects and bytearrays. https://hg.python.org/cpython/rev/976de10bf731 -- nosy: +python-dev ___ Python track

[issue17530] pprint could use line continuation for long bytes literals

2015-03-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue17530] pprint could use line continuation for long bytes literals

2015-02-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch based on current str formatting code (i.e. parenthesis are added only if needed, the space at the right is used more efficiently). It adds pprint support for bytes and bytearrays. Bytes are broken only at positions divisible by 4, so packed 3

[issue17530] pprint could use line continuation for long bytes literals

2014-12-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- dependencies: +pprint doesn't use all width, pprint produces invalid output for long strings versions: +Python 3.5 -Python 3.4 ___ Python tracker __

[issue17530] pprint could use line continuation for long bytes literals

2013-09-27 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue17530] pprint could use line continuation for long bytes literals

2013-04-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, I hadn't noticed that pretty-printing a single string didn't add the parentheses as desired: >>> pprint.pprint("abcd " * 6, width=15) 'abcd abcd ' 'abcd abcd ' 'abcd abcd ' On the other hand, the added parentheses aren't needed when inside a container (li

[issue17530] pprint could use line continuation for long bytes literals

2013-04-17 Thread Pam McA'Nulty
Pam McA'Nulty added the comment: Here's a new version. It looks more like the str_parts patch and uses parentheses instead of continuation as suggested. Sample output: >>> pprint.pprint(b"\n\na\x00", width=1) (b'\n' b'\n' b'a' b'\x00') -- Added file: http://bugs.python.

[issue17530] pprint could use line continuation for long bytes literals

2013-04-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: Well, but eval works if you put parentheses as required by the grammar: >>> s = "(b'xy'\nb'za')" >>> eval(s) b'xyza' Yes, _str_parts and _bytes_parts should probably remain separate. It's the higher-level routine that would deserve sharing. Also, perhaps the o

[issue17530] pprint could use line continuation for long bytes literals

2013-04-15 Thread Pam McA'Nulty
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\\xf

[issue17530] pprint could use line continuation for long bytes literals

2013-04-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't understand why you say that "bytes literals require a continuation character": >>> (b"x" ... b"y") b'xy' >>> [b"x" ... b"y"] [b'xy'] I think the "len caching" is a misoptimization, it's useless here (most CPU time will be sent creating and wrapping

[issue17530] pprint could use line continuation for long bytes literals

2013-04-15 Thread Pam McA'Nulty
Pam McA'Nulty added the comment: oops, forgot to add some samples: >>> pprint.pprint(b"\n\n\n\n\n\n", width=5) b'\n'\ b'\n'\ b'\n'\ b'\n'\ b'\n'\ b'\n' >>> pprint.pprint({"a": b"\x00\xff" * 20}) {'a': b'\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00'\ b'\xff\x00\xff\x

[issue17530] pprint could use line continuation for long bytes literals

2013-04-15 Thread Pam McA'Nulty
Pam McA'Nulty added the comment: Here's a patch. I needed to handle the fact that the repr of a single byte can be 1, 2 or 4 characters long and did not want to wrap in the middle of a byte representation. Note also that bytes literals require a continuation character. In the pathological c

[issue17530] pprint could use line continuation for long bytes literals

2013-03-23 Thread Antoine Pitrou
New submission from Antoine Pitrou: Same as issue #17150: >>> pprint.pprint({"a": b"\x00\xff" * 20}) {'a': b'\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff'} ... could be better f