summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Rose <erik@mozilla.com>2011-11-07 02:40:01 -0800
committerErik Rose <erik@mozilla.com>2011-11-07 02:40:01 -0800
commit605457cb5854e99282f58ec79cccd0ec6564235c (patch)
treeed7c2f53781d07e0b53c3618e16fc86354b97c87
parent5a8b0754f8e841b86d195c395dd299d458d677e8 (diff)
downloadblessings-605457cb5854e99282f58ec79cccd0ec6564235c.tar.gz
Stop crashing when piping to other programs. Bump version to 1.0.1.
-rw-r--r--README.rst4
-rw-r--r--setup.py2
-rw-r--r--terminator/__init__.py4
-rw-r--r--terminator/tests.py16
4 files changed, 22 insertions, 4 deletions
diff --git a/README.rst b/README.rst
index 1eb59dd..83aaf1a 100644
--- a/README.rst
+++ b/README.rst
@@ -177,6 +177,10 @@ Bugs or suggestions? Visit the `issue tracker`_.
Version History
===============
+1.0.1
+ * Fixed a crash when piping output to other programs. Funny how the very act
+ of releasing software causes bugs to emerge, isn't it?
+
1.0
* Extracted Terminator from nose-progressive, my `progress-bar-having,
traceback-shortcutting, rootin', tootin' testrunner`_. It provided the
diff --git a/setup.py b/setup.py
index c0490fc..9ca6184 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ if sys.version_info >= (3,):
setup(
name='terminator',
- version='1.0',
+ version='1.0.1',
description='A thin, practical wrapper around terminal capabilities',
long_description=open('README.rst').read(),
author='Erik Rose',
diff --git a/terminator/__init__.py b/terminator/__init__.py
index b11b47c..481d411 100644
--- a/terminator/__init__.py
+++ b/terminator/__init__.py
@@ -35,7 +35,9 @@ class Terminal(object):
"""
if stream is None:
stream = sys.__stdout__
- if hasattr(stream, 'fileno') and isatty(stream.fileno()):
+ if (hasattr(stream, 'fileno') and
+ callable(stream.fileno) and
+ isatty(stream.fileno())):
# Make things like tigetstr() work:
# (Explicit args make setupterm() work even when -s is passed.)
setupterm(kind or environ.get('TERM', 'unknown'),
diff --git a/terminator/tests.py b/terminator/tests.py
index 0efe6e9..431238f 100644
--- a/terminator/tests.py
+++ b/terminator/tests.py
@@ -1,4 +1,4 @@
-from cStringIO import StringIO
+from StringIO import StringIO
from curses import tigetstr, tparm
import sys
@@ -52,7 +52,7 @@ def test_location():
# Then rip it away, replacing it with something we can check later:
output = t.stream = StringIO()
-
+
with t.location(3, 4):
output.write('hi')
@@ -60,3 +60,15 @@ def test_location():
tparm(tigetstr('cup'), 4, 3) +
'hi' +
tigetstr('rc'))
+
+
+def test_null_fileno():
+ """Make sure ``Terinal`` works when ``fileno`` is ``None``.
+
+ This simulates piping output to another program.
+
+ """
+ out = stream=StringIO()
+ out.fileno = None
+ t = Terminal(stream=out)
+ eq_(t.save, '')