mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
seek() has to accept any int-like number
This commit is contained in:
parent
939336d7d4
commit
3ab4f651b9
1 changed files with 4 additions and 2 deletions
|
@ -694,8 +694,10 @@ class BytesIO(BufferedIOBase):
|
|||
return n
|
||||
|
||||
def seek(self, pos, whence=0):
|
||||
if not isinstance(pos, int):
|
||||
raise TypeError("an integer is required")
|
||||
try:
|
||||
pos = pos.__index__()
|
||||
except AttributeError as err:
|
||||
raise TypeError("an integer is required") from err
|
||||
if whence == 0:
|
||||
self._pos = max(0, pos)
|
||||
elif whence == 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue