Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77cddc3

Browse files
committed
Merge
2 parents c194884 + 219c7b9 commit 77cddc3

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

Lib/bz2.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,18 @@ def _check_not_closed(self):
159159
raise ValueError("I/O operation on closed file")
160160

161161
def _check_can_read(self):
162-
if self.closed:
163-
raise ValueError("I/O operation on closed file")
164162
if self._mode not in (_MODE_READ, _MODE_READ_EOF):
163+
self._check_not_closed()
165164
raise io.UnsupportedOperation("File not open for reading")
166165

167166
def _check_can_write(self):
168-
if self.closed:
169-
raise ValueError("I/O operation on closed file")
170167
if self._mode != _MODE_WRITE:
168+
self._check_not_closed()
171169
raise io.UnsupportedOperation("File not open for writing")
172170

173171
def _check_can_seek(self):
174-
if self.closed:
175-
raise ValueError("I/O operation on closed file")
176172
if self._mode not in (_MODE_READ, _MODE_READ_EOF):
173+
self._check_not_closed()
177174
raise io.UnsupportedOperation("Seeking is only supported "
178175
"on files open for reading")
179176
if not self._fp.seekable():
@@ -322,10 +319,12 @@ def readline(self, size=-1):
322319
non-negative, no more than size bytes will be read (in which
323320
case the line may be incomplete). Returns b'' if already at EOF.
324321
"""
325-
if not hasattr(size, "__index__"):
326-
raise TypeError("Integer argument expected")
327-
size = size.__index__()
322+
if not isinstance(size, int):
323+
if not hasattr(size, "__index__"):
324+
raise TypeError("Integer argument expected")
325+
size = size.__index__()
328326
with self._lock:
327+
self._check_can_read()
329328
# Shortcut for the common case - the whole line is in the buffer.
330329
if size < 0:
331330
end = self._buffer.find(b"\n", self._buffer_offset) + 1
@@ -343,9 +342,10 @@ def readlines(self, size=-1):
343342
further lines will be read once the total size of the lines read
344343
so far equals or exceeds size.
345344
"""
346-
if not hasattr(size, "__index__"):
347-
raise TypeError("Integer argument expected")
348-
size = size.__index__()
345+
if not isinstance(size, int):
346+
if not hasattr(size, "__index__"):
347+
raise TypeError("Integer argument expected")
348+
size = size.__index__()
349349
with self._lock:
350350
return io.BufferedIOBase.readlines(self, size)
351351

Lib/test/test_threaded_import.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,9 @@ def target():
225225
@reap_threads
226226
def test_main():
227227
old_switchinterval = None
228-
# Issue #15599: FreeBSD/KVM cannot handle gil_interval == 1.
229-
new_switchinterval = 0.00001 if 'freebsd' in sys.platform else 0.00000001
230228
try:
231229
old_switchinterval = sys.getswitchinterval()
232-
sys.setswitchinterval(new_switchinterval)
230+
sys.setswitchinterval(1e-5)
233231
except AttributeError:
234232
pass
235233
try:

0 commit comments

Comments
 (0)