Message305018
| Author |
terry.reedy |
| Recipients |
eryksun, isaacl, paul.moore, r.david.murray, steve.dower, terry.reedy, tim.golden, zach.ware |
| Date |
2017年10月26日.01:47:10 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1508982432.0.0.213398074469.issue24920@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
If one starts IDLE from a command-line console (python -m idlelib) or Python console (import idlelib.idle), sys.__stdout__ is the TextIOWraper for that console and .fileno() returns 1. .get_terminal_size() will then return the console size. The exception occurs when IDLE is started from an icon.
Implementing David's suggestion for shutil will be easy: insert just before the fileno call
if not sys.__stdout__: raise ValueError()
This is what os.get_terminal_size() raises on IDLE. Comments in the code in posixpath.c make it clear that this is intended guis and the low_level os function.
This came up today on Stackoverflow when someone tried to use matplotlib.pyplot, which calls os.get_terminal_size, on IDLE.
https://stackoverflow.com/questions/46921087/pyplot-with-idle
(Patching shutil will not help for the os call.) |
|