From: Christian Heimes Date: Fri, 9 Nov 2007 01:27:29 +0000 (+0000) Subject: seek() has to accept any int-like number X-Git-Tag: v3.0a2~209 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ab4f651b906e47650c6b6de94ae23da08db4f58;p=thirdparty%2FPython%2Fcpython.git seek() has to accept any int-like number --- diff --git a/Lib/io.py b/Lib/io.py index d9550ae54a8a..74076d387e0a 100644 --- a/Lib/io.py +++ b/Lib/io.py @@ -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: