summaryrefslogtreecommitdiff
path: root/python/subunit/__init__.py
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2017-10-03 20:24:49 +1300
committerGitHub <noreply@github.com>2017-10-03 20:24:49 +1300
commit12b024344e757949e9928c5e682b7b09fa220b37 (patch)
tree5cea6f3614363d2d12ccd980f02fdceae4223073 /python/subunit/__init__.py
parent7149380ff9a4f77f523b4b82e88b22c4e55a77a6 (diff)
parentdf2c69b59978bd5ba90db298bbae08bbd4e53595 (diff)
downloadsubunit-git-12b024344e757949e9928c5e682b7b09fa220b37.tar.gz
Merge pull request #25 from mtreinish/add-value-error-to-write-only-stream-check
Check for ValueError in write only check in _unwrap_text()
Diffstat (limited to 'python/subunit/__init__.py')
-rw-r--r--python/subunit/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 69acef5..dd3e951 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -1287,15 +1287,17 @@ def _make_binary_on_windows(fileno):
def _unwrap_text(stream):
"""Unwrap stream if it is a text stream to get the original buffer."""
+ exceptions = (_UnsupportedOperation, IOError)
if sys.version_info > (3, 0):
unicode_type = str
else:
unicode_type = unicode
+ exceptions += (ValueError,)
try:
# Read streams
if type(stream.read(0)) is unicode_type:
return stream.buffer
- except (_UnsupportedOperation, IOError):
+ except exceptions:
# Cannot read from the stream: try via writes
try:
stream.write(_b(''))