Message187547
| Author |
ned.deily |
| Recipients |
Tomoki.Imai, ezio.melotti, ned.deily, pradyunsg, r.david.murray, roger.serwy, terry.reedy |
| Date |
2013年04月22日.04:41:51 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1366605711.79.0.327802857531.issue17348@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I think this is another case where confusion is introduced by the behavior of Python 2 interactive mode with regard to encodings. In 2.x Python/pythonrun.c, depending on a number of factors the interactive loop will try to set a more useful encoding on stdin, stdout, and stderr for any of them assigned to a terminal (isatty) This is why the examples using the interpreter (not IDLE) work when the locale env variables (LANG, et al) are set to one that supports Unicode (like "en_US.utf8"). If you changed them to a non-Unicode locale (like "C") and ran the interpreter examples, they wouldn't work. Even clearer, if you used a Unicode-aware text editor to write the examples to files without a # -*- coding: utf-8 -*- directive and tried to run them with /usr/bin/python2.7, you'd get a syntax error. I suspect the issue here is that 2.x IDLE PyShell does not exactly mimic the behavior of the interpreter interactive loop about setting encodings for std*. A side issue is the limitation of Tk's support of non-BMP characters; because of that, it may not possible to fully mimic the interactive interpreter. |
|