mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #11564: Avoid crashes when trying to pickle huge objects or containers
(more than 2**31 items). Instead, in most cases, an OverflowError is raised.
This commit is contained in:
commit
ee763e2acc
5 changed files with 216 additions and 81 deletions
|
@ -1142,7 +1142,7 @@ def bigmemtest(minsize, memuse):
|
|||
return wrapper
|
||||
return decorator
|
||||
|
||||
def precisionbigmemtest(size, memuse):
|
||||
def precisionbigmemtest(size, memuse, dry_run=True):
|
||||
"""Decorator for bigmem tests that need exact sizes.
|
||||
|
||||
Like bigmemtest, but without the size scaling upward to fill available
|
||||
|
@ -1157,10 +1157,11 @@ def precisionbigmemtest(size, memuse):
|
|||
else:
|
||||
maxsize = size
|
||||
|
||||
if real_max_memuse and real_max_memuse < maxsize * memuse:
|
||||
raise unittest.SkipTest(
|
||||
"not enough memory: %.1fG minimum needed"
|
||||
% (size * memuse / (1024 ** 3)))
|
||||
if ((real_max_memuse or not dry_run)
|
||||
and real_max_memuse < maxsize * memuse):
|
||||
raise unittest.SkipTest(
|
||||
"not enough memory: %.1fG minimum needed"
|
||||
% (size * memuse / (1024 ** 3)))
|
||||
|
||||
return f(self, maxsize)
|
||||
wrapper.size = size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue