summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-05-07 01:44:31 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-05-07 01:44:31 (GMT)
commit1bfe9dc871bb3cd6392418410805f0248b1c7d87 (patch)
tree8ea1da7f4758239c2660085d02079cd647a7a1a9 /Lib
parent2e0419dcd69cab245d30b92a7f442fd4617ca8f8 (diff)
downloadcpython-1bfe9dc871bb3cd6392418410805f0248b1c7d87.zip
cpython-1bfe9dc871bb3cd6392418410805f0248b1c7d87.tar.gz
cpython-1bfe9dc871bb3cd6392418410805f0248b1c7d87.tar.bz2
Changed _bytesio.c to avoid comparing a signed with an unsigned value.
Added tests for overflow checks.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_memoryio.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index 1afc363..4604caf 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -7,6 +7,7 @@ import unittest
from test import test_support
import io
+import sys
try:
import _bytesio
@@ -403,6 +404,19 @@ if has_c_implementation:
class CBytesIOTest(PyBytesIOTest):
ioclass = io.BytesIO
+ def test_overflow(self):
+ buf = self.buftype("a")
+ memio = self.ioclass()
+
+ memio.seek(sys.maxsize)
+ self.assertRaises(OverflowError, memio.seek, 1, 1)
+ # Ensure that the position has not been changed
+ self.assertEqual(memio.tell(), sys.maxsize)
+ self.assertEqual(memio.write(self.EOF), 0)
+ self.assertRaises(OverflowError, memio.write, buf)
+ self.assertEqual(memio.tell(), sys.maxsize)
+
+
def test_main():
tests = [PyBytesIOTest, PyStringIOTest]
if has_c_implementation: