Message305076
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.) |
|
Date |
User |
Action |
Args |
2017-10-26 18:05:09 | terry.reedy | set | recipients:
+ terry.reedy, paul.moore, tim.golden, r.david.murray, zach.ware, serhiy.storchaka, eryksun, steve.dower, isaacl |
2017-10-26 18:05:09 | terry.reedy | set | messageid: <1509041109.8.0.213398074469.issue24920@psf.upfronthosting.co.za> |
2017-10-26 18:05:09 | terry.reedy | link | issue24920 messages |
2017-10-26 18:05:09 | terry.reedy | create | |
|