Issue #15989: Fix several occurrences of integer overflow

when result of PyLong_AsLong() narrowed to int without checks.
This commit is contained in:
Serhiy Storchaka 2013-01-15 01:12:17 +02:00
parent 5f1cfbb5c0
commit 7898043868
19 changed files with 148 additions and 24 deletions

View file

@ -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()