Issue 24967: add errors='ignore' to print kwargs (original) (raw)
Issue24967
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) * ![]() |
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) * ![]() |
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:20 | admin | set | github: 69155 |
2015-08-31 16:50:38 | brett.cannon | set | status: open -> closednosy: + brett.cannonmessages: + resolution: rejected |
2015-08-31 09:10:05 | serhiy.storchaka | set | nosy: + serhiy.storchakamessages: + |
2015-08-31 08:17:24 | Lukáš.Němec | create |