summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_poll.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-01-14 23:12:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-01-14 23:12:17 (GMT)
commit78980438683d98076cd541d995a868fb5c9e4277 (patch)
tree6003323bfe4c38f0d9ca17f126fbcdf782752600 /Lib/test/test_poll.py
parent5f1cfbb5c056564e2692d2abcdc82f1944a3b2ec (diff)
downloadcpython-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_poll.py')
-rw-r--r--Lib/test/test_poll.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index 3b7926d..a2fec3d 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -1,6 +1,7 @@
# Test case for the os.poll() function
import os, select, random, unittest, subprocess
+import _testcapi
from test.support import TESTFN, run_unittest
try:
@@ -151,6 +152,15 @@ class PollTests(unittest.TestCase):
if x != 5:
self.fail('Overflow must have occurred')
+ pollster = select.poll()
+ # Issue 15989
+ self.assertRaises(OverflowError, pollster.register, 0,
+ _testcapi.SHRT_MAX + 1)
+ self.assertRaises(OverflowError, pollster.register, 0,
+ _testcapi.USHRT_MAX + 1)
+ self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1)
+ self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1)
+
def test_main():
run_unittest(PollTests)