Message80733
| 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:58 | vstinner | set | recipients:
+ vstinner |
| 2009年01月29日 00:29:58 | vstinner | set | messageid: <1233188998.2.0.237730602839.issue5093@psf.upfronthosting.co.za> |
| 2009年01月29日 00:29:56 | vstinner | link | issue5093 messages |
| 2009年01月29日 00:29:56 | vstinner | create |
|