summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-19 06:04:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-19 06:04:15 (GMT)
commitb94eef2ae3737b1f03452a30d5c96640c838dc46 (patch)
tree7fe16b237f4138c70d900384e52f69e72b89b144 /Lib
parent4ec1590fbf584cbe328230c7b06c64db9b6e3842 (diff)
downloadcpython-b94eef2ae3737b1f03452a30d5c96640c838dc46.zip
cpython-b94eef2ae3737b1f03452a30d5c96640c838dc46.tar.gz
cpython-b94eef2ae3737b1f03452a30d5c96640c838dc46.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)