mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.
This commit is contained in:
parent
5f1cfbb5c0
commit
7898043868
19 changed files with 148 additions and 24 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue