mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +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
|
return n
|
||||||
|
|
||||||
def seek(self, pos, whence=0):
|
def seek(self, pos, whence=0):
|
||||||
if not isinstance(pos, int):
|
try:
|
||||||
raise TypeError("an integer is required")
|
pos = pos.__index__()
|
||||||
|
except AttributeError as err:
|
||||||
|
raise TypeError("an integer is required") from err
|
||||||
if whence == 0:
|
if whence == 0:
|
||||||
self._pos = max(0, pos)
|
self._pos = max(0, pos)
|
||||||
elif whence == 1:
|
elif whence == 1:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue