summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Pipek <jan.pipek@gmail.com>2019-09-10 12:43:46 +0200
committerIlya Etingof <etingof@gmail.com>2019-11-15 19:31:42 +0100
commit5522ba40fd4b0e066cf9415868bfd4aed5508799 (patch)
tree998ded1d9993542ce09f9a4df3e43405805a5b74
parentacc422a26d61237db975d3b4bbb836fc8b5a6ffb (diff)
downloadpyasn1-git-5522ba40fd4b0e066cf9415868bfd4aed5508799.tar.gz
Fail with unseekable streams.
-rw-r--r--pyasn1/codec/ber/decoder.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py
index 8acbf5d..06ef683 100644
--- a/pyasn1/codec/ber/decoder.py
+++ b/pyasn1/codec/ber/decoder.py
@@ -46,13 +46,13 @@ def asSeekableStream(substrate):
try:
if _PY2 and isinstance(substrate, file):
return BytesIO(substrate.read()) # Not optimal for really large files
- elif not substrate.seekable():
- return BufferedReader(substrate, _BUFFER_SIZE)
- else:
+ elif substrate.seekable():
return substrate
+ else:
+ # TODO: Implement for non-seekable streams
+ raise NotImplementedError("Cannot use non-seekable bit stream: " + substrate.__class__.__name__)
except AttributeError as f:
- print(f)
- raise TypeError("Cannot convert " + substrate.__class__.__name__ + " to seekable bit stream.")
+ raise TypeError("Cannot convert " + substrate.__class__.__name__ + " to a seekable bit stream.")
def endOfStream(substrate):