STINNER Victor added the comment: > 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.) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26801> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com