summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-03-29 18:55:12 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-03-29 18:55:12 (GMT)
commit7d037a7b5285093a4fa9906dc22d3dc1bf508b19 (patch)
tree6ff062522cabf97d2b740cc1ce25f9141e434ef8 /Lib/test/test_io.py
parent8e21fb2c69687717f6980e545f54b293c3cf606d (diff)
downloadcpython-7d037a7b5285093a4fa9906dc22d3dc1bf508b19.zip
cpython-7d037a7b5285093a4fa9906dc22d3dc1bf508b19.tar.gz
cpython-7d037a7b5285093a4fa9906dc22d3dc1bf508b19.tar.bz2
Plug another leak, and finally add a test for #1174606 (read() from /dev/zero).
The leak was the reason my previous attempts at testing failed...
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 1b80add..d5be405 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -505,6 +505,22 @@ class IOTest(unittest.TestCase):
with open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"abcxxx")
+ def test_unbounded_file(self):
+ # Issue #1174606: reading from an unbounded stream such as /dev/zero.
+ zero = "/dev/zero"
+ if not os.path.exists(zero):
+ raise unittest.SkipTest("{0} does not exist".format(zero))
+ if sys.maxsize > 0x7FFFFFFF:
+ raise unittest.SkipTest("test can only run in a 32-bit address space")
+ if support.real_max_memuse < support._2G:
+ raise unittest.SkipTest("test requires at least 2GB of memory")
+ with open(zero, "rb", buffering=0) as f:
+ self.assertRaises(OverflowError, f.read)
+ with open(zero, "rb") as f:
+ self.assertRaises(OverflowError, f.read)
+ with open(zero, "r") as f:
+ self.assertRaises(OverflowError, f.read)
+
class CIOTest(IOTest):
pass