classification
Title: problems with shutil.py and os.get_terminal_size
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Dhruve, berker.peksag, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-12-31 11:12 by Dhruve, last changed 2018-05-21 08:17 by Dhruve. This issue is now closed.

Messages (4)
msg309276 - (view) Author: Nick McElwaine (Dhruve) Date: 2017-12-31 11:12
os.get_terminal_size() fails with () or (0) or (1)

shutil.sys fails calling it with (sys.__stdout__.fileno())
 because sys.__stdout__ is type None
msg309279 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-12-31 12:18
The 3.5 branch only gets security fixes at this point. Consider upgrading to 3.6.

That said, this shouldn't be a problem with shutil.get_terminal_size() in 3.5. It handles AttributeError, ValueError, and OSError by returning the `fallback` size. And it's expected that `os.get_terminal_size(1)` will fail if there's no attached console.
msg317024 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-05-18 12:05
Thanks for the report. I agree with Eryk. os.get_terminal_size() is a low-level function. shutil.get_terminal_size() should be used as documented at https://docs.python.org/3/library/os.html#os.get_terminal_size

    shutil.get_terminal_size() is the high-level function which should
    normally be used, os.get_terminal_size is the low-level
    implementation.
msg317219 - (view) Author: Nick McElwaine (Dhruve) Date: 2018-05-21 08:17
Thankyou for clearing that up!

On 18 May 2018 at 13:05, Berker Peksag <report@bugs.python.org> wrote:

>
> Berker Peksag <berker.peksag@gmail.com> added the comment:
>
> Thanks for the report. I agree with Eryk. os.get_terminal_size() is a
> low-level function. shutil.get_terminal_size() should be used as documented
> at https://docs.python.org/3/library/os.html#os.get_terminal_size
>
>     shutil.get_terminal_size() is the high-level function which should
>     normally be used, os.get_terminal_size is the low-level
>     implementation.
>
> ----------
> nosy: +berker.peksag
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue32463>
> _______________________________________
>
History
Date User Action Args
2018-05-21 08:17:16Dhruvesetmessages: + msg317219
2018-05-18 12:05:37berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg317024

resolution: not a bug
stage: resolved
2017-12-31 12:18:32eryksunsetnosy: + eryksun
messages: + msg309279
components: + Library (Lib)
2017-12-31 11:12:31Dhruvecreate