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 <1427762131.71.0.587113462689.issue19100@psf.upfronthosting.co.za>
In-reply-to
Content
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: <https://bitbucket.org/Gfy/pyrescene/src/560cafe/rescene/utility.py#cl-426>. Python 3 only version: <https://github.com/vadmium/python-iview/commit/68b0559>. 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.
History
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: <1427762131.71.0.587113462689.issue19100@psf.upfronthosting.co.za>
2015-03-31 00:35:31martin.panterlinkissue19100 messages
2015-03-31 00:35:29martin.pantercreate