summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
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)