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.

classification
Title: add errors='ignore' to print kwargs
Type: Stage:
Components: Versions: Python 3.6, Python 3.3, Python 3.4, Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Lukáš.Němec, brett.cannon, serhiy.storchaka
Priority: normal Keywords:

Created on 2015-08-31 08:17 by Lukáš.Němec, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg249389 - (view) Author: Lukáš Němec (Lukáš.Němec) Date: 2015-08-31 08:17
Please add errors='...' to print's kwargs and pass it to codecs that are called from print. Sometimes you have undecodable/unencodable characters that you want to remove from the printed text.

Now you need to call 'mytext'.encode('enc', errors='replace').decode('enc') to achieve the same result. This would be just a shortcut.

Thank you :)
msg249394 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-08-31 09:10
print() doesn't encode characters. It just writes string representation of arguments to output text file (sys.stdout by default). It is the output file is responsible for encoding (or is not, if it saves or passes further a text directly, as StringIO).
msg249414 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-08-31 16:50
I agree with Serhiy that this isn't print's job to worry about. It's better to be explicit than implicit and trying to cram worrying about decoding errors conflates what print does.

I'm closing as "rejected". Thanks for the suggestion, though, Lukáš.
History
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69155
2015-08-31 16:50:38brett.cannonsetstatus: open -> closed

nosy: + brett.cannon
messages: + msg249414

resolution: rejected
2015-08-31 09:10:05serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg249394
2015-08-31 08:17:24Lukáš.Němeccreate