summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-07 12:14:25 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-07 12:14:25 (GMT)
commit1f3b4e12e8ba9cd896625ba02ea1ab6849ca3a07 (patch)
tree42dc10540da9b1aff1d4e6cef51e4c11ce4f5b47 /Lib/_pyio.py
parent2a4ab816332a67150fcc8ece255fb1ee8e66af83 (diff)
downloadcpython-1f3b4e12e8ba9cd896625ba02ea1ab6849ca3a07.zip
cpython-1f3b4e12e8ba9cd896625ba02ea1ab6849ca3a07.tar.gz
cpython-1f3b4e12e8ba9cd896625ba02ea1ab6849ca3a07.tar.bz2
Fix some py3k warnings in the standard library.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index a1c21d3..8098681 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -839,8 +839,8 @@ class BytesIO(BufferedIOBase):
if self.closed:
raise ValueError("seek on closed file")
try:
- pos = pos.__index__()
- except AttributeError as err:
+ pos.__index__
+ except AttributeError:
raise TypeError("an integer is required")
if whence == 0:
if pos < 0:
@@ -864,8 +864,13 @@ class BytesIO(BufferedIOBase):
raise ValueError("truncate on closed file")
if pos is None:
pos = self._pos
- elif pos < 0:
- raise ValueError("negative truncate position %r" % (pos,))
+ else:
+ try:
+ pos.__index__
+ except AttributeError:
+ raise TypeError("an integer is required")
+ if pos < 0:
+ raise ValueError("negative truncate position %r" % (pos,))
del self._buffer[pos:]
return pos
@@ -1813,6 +1818,10 @@ class TextIOWrapper(TextIOBase):
if n is None:
n = -1
decoder = self._decoder or self._get_decoder()
+ try:
+ n.__index__
+ except AttributeError:
+ raise TypeError("an integer is required")
if n < 0:
# Read everything.
result = (self._get_decoded_chars() +