summaryrefslogtreecommitdiff
path: root/Lib/test/test_resource.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-04 12:47:24 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-04 12:47:24 +0200
commit19c4e0df29234355074fe7ec67857f0a0b7e0a18 (patch)
tree55fc3001eeeb6613b9dbe948da9a1ec51c44f3c8 /Lib/test/test_resource.py
parent64359d203e95f243eec661baa4226509a8bb2909 (diff)
downloadcpython-git-19c4e0df29234355074fe7ec67857f0a0b7e0a18.tar.gz
Issue #6083: Fix multiple segmentation faults occured when PyArg_ParseTuple
parses nested mutating sequence.
Diffstat (limited to 'Lib/test/test_resource.py')
-rw-r--r--Lib/test/test_resource.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 3c9b620702..f3416b7b43 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -107,6 +107,23 @@ class ResourceTest(unittest.TestCase):
except (ValueError, AttributeError):
pass
+ # Issue 6083: Reference counting bug
+ def test_setrusage_refcount(self):
+ try:
+ limits = resource.getrlimit(resource.RLIMIT_CPU)
+ except AttributeError:
+ pass
+ else:
+ class BadSequence:
+ def __len__(self):
+ return 2
+ def __getitem__(self, key):
+ if key in (0, 1):
+ return len(tuple(range(1000000)))
+ raise IndexError
+
+ resource.setrlimit(resource.RLIMIT_CPU, BadSequence())
+
def test_main(verbose=None):
support.run_unittest(ResourceTest)