This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients doerwalter, ezio.melotti, fdrake, martin.panter, pitrou, serhiy.storchaka
Date 2015-03-31.00:35:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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? Your mock test case sets encoding="latin1" with no buffer, but that class will also write non-latin1 strings, so there is no problem.

Also I wonder if flushing the stream once or twice for each pprint() call is a wise move.

Another way to tackle this might be a function that translates the non-Latin-1 or whatever characters, allowing the original write() or whatever method to still be used. Here is a Python 2 and 3 compatible attempt: <>. Python 3 only version: <>. This function is originally used for printing descriptive comments to stdout (alongside other text where the “strict” error handler is appropriate). But I think it could be generally usable for pprint(), sys.displayhook(), etc as well.
Date User Action Args
2015-03-31 00:35:31martin.pantersetrecipients: + martin.panter, fdrake, doerwalter, pitrou, ezio.melotti, serhiy.storchaka
2015-03-31 00:35:31martin.pantersetmessageid: <>
2015-03-31 00:35:31martin.panterlinkissue19100 messages
2015-03-31 00:35:29martin.pantercreate