[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Jerzy
Jerzy added the comment: good point! I will give it a try Jerzy Martin v. Löwis wrote: > Martin v. Löwis added the comment: > > If you want to switch to a different language, consider switching to > Python 3. There, all strings are Unicode strings, and files opened in > text mode always use

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: If you want to switch to a different language, consider switching to Python 3. There, all strings are Unicode strings, and files opened in text mode always use the locale encoding. -- ___ Python tracker

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Jerzy
Jerzy added the comment: OK, I give up. The problem is that one might test a program on terminal and think that everything is running OK and then spend a reasonable amount of time trying to find the problem later Another approach: couldn't utf8 be set as default encoding for all inputs and

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: Using the terminal encoding for sys.stdout does not work in the general case, as a (background) process may not *have* a controlling terminal (such as a CGI script, a cron job, or a Windows service). That Python recognizes the terminal encoding is primarily a c

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Jerzy
Jerzy added the comment: Well, I would suggest using the terminal encoding as default one when redirecting. In my opinion sys.stdin and sys.stdout should always have the terminal encoding Alternatively you could make the function sys.setdefaultencoding() visible to change it in a reasonable

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Georg Brandl
Georg Brandl added the comment: When output goes to a terminal, Python can determine its encoding. For a file, it cannot, therefore it refuses to guess. Also, many programs behave differently when used with redirection; namely, all those that use `isatty()` to determine if stdout is a terminal.

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Jerzy
Jerzy added the comment: I know how to make it work. The question is why outputting to file makes it crush when outputting to terminal does not. I have never seen "$program > file" behaving in a different way than "$program" in any other language Jerzy Orlowski Benjamin Peterson wrote: > Be

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Benjamin Peterson
Benjamin Peterson added the comment: You have to use an encoding that's not ascii then. -- nosy: +benjamin.peterson resolution: -> works for me status: open -> closed ___ Python tracker ___

[issue6832] Outputting unicode crushes when printing to file on Linux

2009-09-03 Thread Jerzy
New submission from Jerzy : Hi When I am outputting unicode strings to terminal my script works OK, but when I redirect it to file I get a crash: $ python mailing/message_sender.py -l Bia Białystok $ python mailing/message_sender.py -l Bia > ~/tmp/aaa.txt Traceback (most recent call last):