[issue19100] Use backslashreplace in pprint

2017-12-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Try with LANG=en_US. And even UTF-8 can fail. -- ___ Python tracker ___

[issue19100] Use backslashreplace in pprint

2017-12-18 Thread STINNER Victor
STINNER Victor added the comment: $ LANG= ./python -c "import pprint; pprint.pprint('\u20ac')" Thanks to the PEP 538 and PEP 540, this command now works as expected in Python 3.7: vstinner@apu$ LANG= python3.7 -c "import pprint; pprint.pprint('\u20ac')" '€' Do we

[issue19100] Use backslashreplace in pprint

2015-03-31 Thread Walter Dörwald
Walter Dörwald added the comment: The linked code at https://github.com/vadmium/python-iview/commit/68b0559 seems strange to me: try: text.encode(encoding, textio.errors or strict) except UnicodeEncodeError: text = text.encode(encoding, errors).decode(encoding)

[issue19100] Use backslashreplace in pprint

2015-03-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What is the reasoning behind the DecodeWriter case, where the original stream has an interesting encoding, but “buffer” is None? Are there any real-world cases like that? sys.stdout and sys.stderr in IDLE. --

[issue19100] Use backslashreplace in pprint

2015-03-31 Thread Martin Panter
Martin Panter added the comment: Walter: the first line encoding with textio.errors is meant to handle the case where the output stream already has its own permissive error handler set. But anyway I was just trying to point out that it might be better to do the backslash escaping at the text

[issue19100] Use backslashreplace in pprint

2015-03-30 Thread Martin Panter
Martin Panter added the comment: I agree with Serhiy that using a permissive error handler with pprint() is appropriate. What is the reasoning behind the DecodeWriter case, where the original stream has an interesting encoding, but “buffer” is None? Are there any real-world cases like that?

[issue19100] Use backslashreplace in pprint

2013-12-14 Thread Walter Dörwald
Walter Dörwald added the comment: sys.displayhook doesn't fail, because it uses the backslashreplace error handler, and for sys.displayhook that's OK, because it's only used for screen output and there some output is better than no output. However print and pprint.pprint might be used for

[issue19100] Use backslashreplace in pprint

2013-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The purpose of pprint.pprint() is to produce human-readable output. In this case some output is better than nothing. It isn't designed to be parseable by other programs, because sometimes it is even less accurate than the result of repr() (pprint()

[issue19100] Use backslashreplace in pprint

2013-12-11 Thread Walter Dörwald
Walter Dörwald added the comment: This is not the fault of pprint. IMHO it doesn't make sense to fix anything here, at least not for pprint specifically. print() has the same problem: $ LANG= ./python -c print('\u20ac')

[issue19100] Use backslashreplace in pprint

2013-12-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: pprint is not print. print('\u20ac') € import pprint; pprint.pprint('\u20ac') '€' Default sys.displayhook doesn't fail on unencodable output. $ LANG=C ./python Python 3.4.0b1 (default:e961a166dc70+, Dec 11 2013, 13:57:17) [GCC 4.6.3] on linux Type help,

[issue19100] Use backslashreplace in pprint

2013-12-11 Thread Fred L. Drake, Jr.
Changes by Fred L. Drake, Jr. fdr...@gmail.com: -- assignee: - fdrake ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19100 ___ ___

[issue19100] Use backslashreplace in pprint

2013-12-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: In new patch wrapping stream is moved to PrettyPrinter constructor. -- Added file: http://bugs.python.org/file33084/pprint_unencodable_2.patch ___ Python tracker rep...@bugs.python.org

[issue19100] Use backslashreplace in pprint

2013-12-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Any review? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19100 ___ ___ Python-bugs-list mailing list

[issue19100] Use backslashreplace in pprint

2013-09-27 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: Currently pprint.pprint() fails on unencodable characters. $ LANG=en_US.utf8 ./python -c import pprint; pprint.pprint('\u20ac') '€' $ LANG= ./python -c import pprint; pprint.pprint('\u20ac') Traceback (most recent call last): File string, line 1, in