diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-08-29 21:09:33 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-08-29 21:09:33 (GMT) |
commit | 82be19f889e97618d73f405ad53ceffbee462008 (patch) | |
tree | 7d9dd159ec8bd79151e0afb8dc3d2947cc859f82 /Lib/test/support.py | |
parent | aa26b275034c07784c4d64e9a2bc26c742577327 (diff) | |
download | cpython-82be19f889e97618d73f405ad53ceffbee462008.zip cpython-82be19f889e97618d73f405ad53ceffbee462008.tar.gz cpython-82be19f889e97618d73f405ad53ceffbee462008.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r-- | Lib/test/support.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index e82a4f9..8e6ca2a 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -1089,7 +1089,7 @@ def bigmemtest(minsize, memuse): return wrapper return decorator -def precisionbigmemtest(size, memuse): +def precisionbigmemtest(size, memuse, dry_run=True): def decorator(f): def wrapper(self): size = wrapper.size @@ -1099,10 +1099,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 |