diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-09 01:27:29 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-09 01:27:29 (GMT) |
commit | 3ab4f651b906e47650c6b6de94ae23da08db4f58 (patch) | |
tree | a3925664a0898658f0fadb843b145e3d6c1eb90c | |
parent | 939336d7d47cd22c96e1220a6895c897167dd5f7 (diff) | |
download | cpython-3ab4f651b906e47650c6b6de94ae23da08db4f58.zip cpython-3ab4f651b906e47650c6b6de94ae23da08db4f58.tar.gz cpython-3ab4f651b906e47650c6b6de94ae23da08db4f58.tar.bz2 |
seek() has to accept any int-like number
-rw-r--r-- | Lib/io.py | 6 |
1 files changed, 4 insertions, 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: |