[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Uh, sorry for the noise. I see now that shutil was already patched by Victor 
and you in #26801, so that it already works with IDLE started from an icon.  So 
now I don't understand your last comment, "Patching shutil will help for 
pandas."

--
resolution:  -> duplicate
stage: test needed -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I think it is better to open a new issue for a new feature. The bug reported in 
this issue two years ago already is fixed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I am preparing a PR for shutil.get_window_size.  Pyplot should probably call 
that instead of the os version.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Patching shutil will help for pandas.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

What do you want to do Terry?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

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.)

--
resolution: out of date -> 
stage: resolved -> test needed
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-26 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

This issue already is fixed in 3.5 (see issue26801). The Stackoverflow question 
is related to 3.4 which is too old for getting this fix.

I'm wondering if it is worth to patch shutil.get_terminal_size() in IDLE so 
that it will return the size of PyShell output window (in characters).

--
nosy: +serhiy.storchaka
resolution:  -> out of date
stage: test needed -> resolved
status: open -> closed
superseder:  -> Fix shutil.get_terminal_size() to catch AttributeError

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2017-10-25 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

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.)

--
nosy: +terry.reedy
stage:  -> test needed
type: crash -> behavior
versions: +Python 3.7 -Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2015-08-26 Thread R. David Murray

R. David Murray added the comment:

I think checking for None would be better.  Catching Exception might mask other 
errors that the user would want to know about.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24920
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2015-08-25 Thread Isaac Levy

Isaac Levy added the comment:

I guess users need to check standard streams for None. There's not many uses of 
stream attributes in core libs.

Maybe catch should be Exception -- since it's documented to return a fallback 
on error.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24920
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2015-08-23 Thread eryksun

eryksun added the comment:

FYI, the size of the terminal associated with the C's stdout isn't related to 
the IDLE shell. For example, in Linux when I run IDLE from the GUI, the 
associated terminal size is 0x0. 

On Windows, os.get_terminal_size uses the console API 
GetConsoleScreenBufferInfo. This can't work given IDLE has no attached console. 
Also, for a GUI app the Windows C runtime leaves the standard FILE streams 
uninitialized to an invalid file descriptor (-1), so Python's sys.__stdout__ is 
None. That's why you get an AttributeError complaining that NoneType (i.e. 
type(None)) has no attribute 'fileno'.

Currently shutil.get_terminal_size returns the fallback size when 
os.get_terminal_size(sys.__stdout__.fileno()) raises NameError or OSError. I 
think AttributeError and ValueError should be added to this list.

--
components: +Windows -IDLE
nosy: +eryksun, paul.moore, steve.dower, tim.golden, zach.ware
versions: +Python 3.5, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24920
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24920] shutil.get_terminal_size throws AttributeError

2015-08-23 Thread Isaac Levy

New submission from Isaac Levy:

OS: windows 7, python 3.4.3, tk version 8.6.1

os.get_terminal_size also fails.


 shutil.get_terminal_size()
Traceback (most recent call last):
  File pyshell#4, line 1, in module
shutil.get_terminal_size()
  File C:\Python34\lib\shutil.py, line 1058, in get_terminal_size
size = os.get_terminal_size(sys.__stdout__.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'
 os.get_terminal_size()
Traceback (most recent call last):
  File pyshell#5, line 1, in module
os.get_terminal_size()
ValueError: bad file descriptor

--
components: IDLE
messages: 249039
nosy: Isaac Levy
priority: normal
severity: normal
status: open
title: shutil.get_terminal_size throws AttributeError
type: crash
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24920
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com