Commit 138ad506 authored by Nadeem Vawda's avatar Nadeem Vawda

Fix error handling in new fast path of BZ2File.readline().

parent 452add08
...@@ -323,6 +323,7 @@ class BZ2File(io.BufferedIOBase): ...@@ -323,6 +323,7 @@ class BZ2File(io.BufferedIOBase):
raise TypeError("Integer argument expected") raise TypeError("Integer argument expected")
size = size.__index__() size = size.__index__()
with self._lock: with self._lock:
self._check_can_read()
# Shortcut for the common case - the whole line is in the buffer. # Shortcut for the common case - the whole line is in the buffer.
if size < 0: if size < 0:
end = self._buffer.find(b"\n", self._buffer_offset) + 1 end = self._buffer.find(b"\n", self._buffer_offset) + 1
......
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