]> granicus.if.org Git - python/commitdiff
seek() has to accept any int-like number
authorChristian Heimes <christian@cheimes.de>
Fri, 9 Nov 2007 01:27:29 +0000 (01:27 +0000)
committerChristian Heimes <christian@cheimes.de>
Fri, 9 Nov 2007 01:27:29 +0000 (01:27 +0000)
Lib/io.py

index d9550ae54a8a57a45d56cb0258d2611f05831b99..74076d387e0ae3d1fd4cc002e825eb68ded00614 100644 (file)
--- 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: