This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients abarry, martin.panter, serhiy.storchaka, vstinner
Date 2016-04-19.19:39:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461094748.33.0.716684245783.issue26801@psf.upfronthosting.co.za>
In-reply-to
Content
> Hmm, if `sys.__stdout__` was deleted (or set to `None`), this would also raise an `AttributeError` when calling `shutil.get_terminal_size`, so I think that even if `os.get_terminal_size` is guaranteed to be always present (which it's not, IIUC), catching `AttributeError` would prevent that bug, too.

It would be nice to have an unit test too for this case. You can use something like:

with unittest.mock.patch('shutil.sys') as mock_sys:
    del mock_sys.__stdout__
    print(shutil.get_terminal_size((3, 3)))

(and mock also os.envion, as shown in the review.)
History
Date User Action Args
2016-04-19 19:39:08vstinnersetrecipients: + vstinner, martin.panter, serhiy.storchaka, abarry
2016-04-19 19:39:08vstinnersetmessageid: <1461094748.33.0.716684245783.issue26801@psf.upfronthosting.co.za>
2016-04-19 19:39:08vstinnerlinkissue26801 messages
2016-04-19 19:39:08vstinnercreate