mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #20191: Fixed a crash in resource.prlimit() when pass a sequence that
doesn't own its elements as limits.
This commit is contained in:
parent
4ec1590fbf
commit
b94eef2ae3
3 changed files with 48 additions and 33 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue