diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-14 23:12:17 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-14 23:12:17 (GMT) |
commit | 78980438683d98076cd541d995a868fb5c9e4277 (patch) | |
tree | 6003323bfe4c38f0d9ca17f126fbcdf782752600 /Lib/test/test_io.py | |
parent | 5f1cfbb5c056564e2692d2abcdc82f1944a3b2ec (diff) | |
download | cpython-78980438683d98076cd541d995a868fb5c9e4277.zip cpython-78980438683d98076cd541d995a868fb5c9e4277.tar.gz cpython-78980438683d98076cd541d995a868fb5c9e4277.tar.bz2 |
Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.
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 7906060..8727dde 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -32,6 +32,7 @@ import time import unittest import warnings import weakref +import _testcapi from collections import deque, UserList from itertools import cycle, count from test import support @@ -1970,6 +1971,14 @@ class TextIOWrapperTest(unittest.TestCase): os.environ.clear() os.environ.update(old_environ) + # 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() |