On Thu, Jun 4, 2009 at 10:06 PM, Ben Finney <ben+pyt...@benfinney.id.au<ben%2bpyt...@benfinney.id.au> > wrote:
> Ron Garret <rnospa...@flownet.com> writes: > > > Python 2.6.2 on OS X 10.5.7: > > > > [...@mickey:~]$ echo $LANG > > en_US.UTF-8 > > [...@mickey:~]$ cat frob.py > > #!/usr/bin/env python > > print u'\u03BB' > > > > [...@mickey:~]$ ./frob.py > > ª > > [...@mickey:~]$ ./frob.py > foo > > Traceback (most recent call last): > > File "./frob.py", line 2, in <module> > > print u'\u03BB' > > UnicodeEncodeError: 'ascii' codec can't encode character u'\u03bb' in > > position 0: ordinal not in range(128) > > I get the same behaviour on Debian GNU/Linux, python 2.5.2. It's > certainly not desirable; the terminal, the shell, and the filesystem are > all using UTF-8 so it should work fine. > > You might be best advised to report this as a bug to the Python bug > tracker <URL:http://bugs.python.org/>. > Please don't. This isn't a bug- it's actually a good default. If the user doesn't specify an encoding, Python refuses to guess. In the case of the terminal, python doesn't have to guess because the environment variables give the encoding. When it's writing to a file, there is no way to know what encoding to use so it just sticks with ascii. > > -- > \ “I fly Air Bizarre. You buy a combination one-way round-trip | > `\ ticket. Leave any Monday, and they bring you back the previous | > _o__) Friday. That way you still have the weekend.” —Steven Wright | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list