diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-19 10:26:26 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-19 10:26:26 (GMT) |
commit | 441d30fac7f4037e4a79e4ada873de3b6f6e5a26 (patch) | |
tree | a406cb41f1b78476445786f408b95b1cd0bdb7a6 /Lib/test/test_io.py | |
parent | ff12fae80e15ad29ae2557d23e70f6ff9365b31f (diff) | |
download | cpython-441d30fac7f4037e4a79e4ada873de3b6f6e5a26.zip cpython-441d30fac7f4037e4a79e4ada873de3b6f6e5a26.tar.gz cpython-441d30fac7f4037e4a79e4ada873de3b6f6e5a26.tar.bz2 |
Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.
This is a backport of changesets 13e2e44db99d and 525407d89277.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 56ac2c8..249dc30 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -31,6 +31,7 @@ import signal import errno import warnings import pickle +import _testcapi from itertools import cycle, count from collections import deque, UserList from test import support @@ -1903,6 +1904,14 @@ class TextIOWrapperTest(unittest.TestCase): t.write("A\rB") self.assertEqual(r.getvalue(), b"XY\nZA\rB") + # Issue 15989 + def test_device_encoding(self): + b = self.BytesIO() + b.fileno = lambda: _testcapi.INT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + b.fileno = lambda: _testcapi.UINT_MAX + 1 + self.assertRaises(OverflowError, self.TextIOWrapper, b) + def test_encoding(self): # Check the encoding attribute is always set, and valid b = self.BytesIO() |