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.

Author vstinner
Recipients vstinner
Date 2009-01-29.00:29:56
SpamBayes Score 7.219225e-13
Marked as misclassified No
Message-id <1233188998.2.0.237730602839.issue5093@psf.upfronthosting.co.za>
In-reply-to
Content
If Python output is redirected to a pipe, sys.stdout encoding is 
ASCII. So "2to3 script.py|cat" will write the patch in ASCII. If the 
script contains a non-ASCII character, 2to3 fails with:
  ...
  File ".../lib2to3/refactor.py", line 238, in refactor_file
    self.processed_file(str(tree)[:-1], filename, write=write)
  File ".../lib2to3/refactor.py", line 342, in processed_file
    self.print_output(diff_texts(old_text, new_text, filename))
  File ".../main.py", line 48, in print_output
    print(line)
UnicodeEncodeError: 'ascii' codec can't encode character '\xfb' in 
position 11: ordinal not in range(128)

Should we consider the input file and stdout as binary files? 
Workaround: modify the files in place (-w option) but don't write the 
patch to stdout (no such option yet).

A project may contain scripts in ASCII, Latin-1 and UTF-8 (eg. Python 
source code ;-)).
History
Date User Action Args
2009-01-29 00:29:58vstinnersetrecipients: + vstinner
2009-01-29 00:29:58vstinnersetmessageid: <1233188998.2.0.237730602839.issue5093@psf.upfronthosting.co.za>
2009-01-29 00:29:56vstinnerlinkissue5093 messages
2009-01-29 00:29:56vstinnercreate