summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-19 06:07:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-19 06:07:29 (GMT)
commit932ee73188c73bbe63834f69566a4f188fbf43a7 (patch)
treee6714c5150ba9fd0939b409f5553aea4c6319ce1 /Lib
parent39d60fa9269e129219077288f10541317f1b9374 (diff)
parent879199ba11947d9765b06806df54566fde75d498 (diff)
downloadcpython-932ee73188c73bbe63834f69566a4f188fbf43a7.zip
cpython-932ee73188c73bbe63834f69566a4f188fbf43a7.tar.gz
cpython-932ee73188c73bbe63834f69566a4f188fbf43a7.tar.bz2
Issue #20191: Fixed a crash in resource.prlimit() when pass a sequence that
doesn't own its elements as limits.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_resource.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 2ecae0f..cc9c570 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -158,6 +158,20 @@ class ResourceTest(unittest.TestCase):
self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS, limit),
limit)
+ # Issue 20191: Reference counting bug
+ @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
+ @support.requires_linux_version(2, 6, 36)
+ def test_prlimit_refcount(self):
+ class BadSeq:
+ def __len__(self):
+ return 2
+ def __getitem__(self, key):
+ return limits[key] - 1 # new reference
+
+ limits = resource.getrlimit(resource.RLIMIT_AS)
+ self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS, BadSeq()),
+ limits)
+
def test_main(verbose=None):
support.run_unittest(ResourceTest)