seek() has to accept any int-like number

This commit is contained in:
Christian Heimes 2007-11-09 01:27:29 +00:00
parent 939336d7d4
commit 3ab4f651b9

View file

@ -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: