aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-13 15:26:44 +0000
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-13 15:26:44 +0000
commitb14930cd93e74cae3b7370262c6dcc7c28e0e712 (patch)
treedaca91cb5ed347957f3ad629ff9be93f0f1af4a4 /Lib/_pyio.py
parentBlocked revisions 78926 via svnmerge (diff)
downloadcpython-b14930cd93e74cae3b7370262c6dcc7c28e0e712.tar.gz
cpython-b14930cd93e74cae3b7370262c6dcc7c28e0e712.tar.bz2
cpython-b14930cd93e74cae3b7370262c6dcc7c28e0e712.zip
Only the parts which are relevant for 3.x branch.
Merged revisions 78757-78758,78769,78815 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78757 | florent.xicluna | 2010-03-07 13:14:25 +0100 (dim, 07 mar 2010) | 2 lines Fix some py3k warnings in the standard library. ........ r78758 | florent.xicluna | 2010-03-07 13:18:33 +0100 (dim, 07 mar 2010) | 4 lines Issue #7849: Now the utility ``check_warnings`` verifies if the warnings are effectively raised. A new utility ``check_py3k_warnings`` deals with py3k warnings. ........ r78769 | florent.xicluna | 2010-03-07 20:14:12 +0100 (dim, 07 mar 2010) | 2 lines Refresh the documentation for the test.test_support module. ........ r78815 | florent.xicluna | 2010-03-09 20:57:01 +0100 (mar, 09 mar 2010) | 2 lines #7772: Fix test_py3kwarn. Now the test suite could pass with "-3" flag. ........
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 8960ce92557..c58548e7ee0 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -828,7 +828,7 @@ class BytesIO(BufferedIOBase):
if self.closed:
raise ValueError("seek on closed file")
try:
- pos = pos.__index__()
+ pos.__index__
except AttributeError as err:
raise TypeError("an integer is required") from err
if whence == 0:
@@ -853,8 +853,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 as err:
+ raise TypeError("an integer is required") from err
+ if pos < 0:
+ raise ValueError("negative truncate position %r" % (pos,))
del self._buffer[pos:]
return pos
@@ -1803,6 +1808,10 @@ class TextIOWrapper(TextIOBase):
if n is None:
n = -1
decoder = self._decoder or self._get_decoder()
+ try:
+ n.__index__
+ except AttributeError as err:
+ raise TypeError("an integer is required") from err
if n < 0:
# Read everything.
result = (self._get_decoded_chars() +