Commit bbd54e15 authored by jbd's avatar jbd

Check for fileno attribute in _tty_width function

When using Options parser within a unittest.TextTestRunner with buffering enabled (buffer=True), it fails with: 
AttributeError: StringIO instance has no attribute 'fileno'

This change will prevent this kind of error.
parent 00f20657
...@@ -61,6 +61,8 @@ def _remove_negative_k(k): ...@@ -61,6 +61,8 @@ def _remove_negative_k(k):
def _tty_width(): def _tty_width():
if not hasattr(sys.stderr, "fileno"):
return _atoi(os.environ.get('WIDTH')) or 70
s = struct.pack("HHHH", 0, 0, 0, 0) s = struct.pack("HHHH", 0, 0, 0, 0)
try: try:
import fcntl import fcntl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment