Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-27 Thread eryk sun
On Mon, Mar 27, 2017 at 8:52 PM, Barry wrote: > I took to using > > chcp 65001 > > This puts cmd.exe into unicode mode. conhost.exe hosts the console, and chcp.com is a console app that calls GetConsoleCP, SetConsoleCP and SetConsoleOutputCP to show or modify the

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-27 Thread Barry
I took to using chcp 65001 This puts cmd.exe into unicode mode. Of course the python 3.6 make this uneccesary i understand. Barry > On 24 Mar 2017, at 15:41, Ryan Gonzalez wrote: > > Recently, I was working on a Windows GUI application that ends up running > ffmpeg,

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-27 Thread Nick Coghlan
On 27 March 2017 at 13:10, Steve Dower wrote: > On 26Mar2017 0707, Nick Coghlan wrote: >> >> Perhaps it would be worth noting in the table of error handlers at >> https://docs.python.org/3/library/codecs.html#error-handlers that >> backslashreplace is used by the `ascii()`

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Steve Dower
On 26Mar2017 0707, Nick Coghlan wrote: Perhaps it would be worth noting in the table of error handlers at https://docs.python.org/3/library/codecs.html#error-handlers that backslashreplace is used by the `ascii()` builtin and the associated format specifiers backslashreplace is also the

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Michel Desmoulin
Le 26/03/2017 à 10:31, Victor Stinner a écrit : > print(msg) calls sys.stdout.write(msg): write() expects text, not bytes. What you are saying right now is that the API is not granular enough to just add a parameter. Not that it can't be done. It just mean we need to expose stdout.write()

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Ryan Gonzalez
FWIW, using the ascii function does have the problem that Unicose characters will be escaped, even if the terminal could have handled them perfectly fine. -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Mar 26, 2017 9:07 AM, "Nick

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Nick Coghlan
On 26 March 2017 at 18:31, Victor Stinner wrote: > print(msg) calls sys.stdout.write(msg): write() expects text, not bytes. I > dislike the idea of putting encoding options in print. It's too specific. > What if tomorrow you replace print() with file.write()? Do you want

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Victor Stinner
print(msg) calls sys.stdout.write(msg): write() expects text, not bytes. I dislike the idea of putting encoding options in print. It's too specific. What if tomorrow you replace print() with file.write()? Do you want to add errors there too? No, it's better to write own formatter function as

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-25 Thread Michel Desmoulin
Le 24/03/2017 à 17:37, Victor Stinner a écrit : > *If* we change something, I would prefer to modify sys.stdout. The > following issue proposes to add > sys.stdout.set_encoding(errors='replace'): > http://bugs.python.org/issue15216 > > You can already set the PYTHONIOENCODING environment

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Paul Moore
On 24 March 2017 at 16:37, Victor Stinner wrote: > *If* we change something, I would prefer to modify sys.stdout. The > following issue proposes to add > sys.stdout.set_encoding(errors='replace'): > http://bugs.python.org/issue15216 I thought I recalled seeing something

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Guido van Rossum
On Fri, Mar 24, 2017 at 9:37 AM, Victor Stinner wrote: > *If* we change something, I would prefer to modify sys.stdout. The > following issue proposes to add > sys.stdout.set_encoding(errors='replace'): > http://bugs.python.org/issue15216 > I like that. > You can

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Victor Stinner
*If* we change something, I would prefer to modify sys.stdout. The following issue proposes to add sys.stdout.set_encoding(errors='replace'): http://bugs.python.org/issue15216 You can already set the PYTHONIOENCODING environment variable to ":replace" to use "replace" on sys.stdout (and

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Paul Moore
On 24 March 2017 at 15:41, Ryan Gonzalez wrote: > Recently, I was working on a Windows GUI application that ends up running > ffmpeg, and I wanted to see the command that was being run. However, the > file name had a Unicode character in it (it's a Sawano song), and when I >

[Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Ryan Gonzalez
Recently, I was working on a Windows GUI application that ends up running ffmpeg, and I wanted to see the command that was being run. However, the file name had a Unicode character in it (it's a Sawano song), and when I tried to print it to the console, it crashed during the encode/decode. (The