diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-08-29 23:14:53 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-08-29 23:14:53 +0200 |
commit | ee763e2acc469fa2f423440517b9bc227fbbe79c (patch) | |
tree | 07daf6aa29d762ccc1c5f7fd1fc09196dcf1b13b /Lib/test/support.py | |
parent | 466517df0e272f1b5d46d4e5eed112cefec3d7e3 (diff) | |
parent | 82be19f889e97618d73f405ad53ceffbee462008 (diff) | |
download | cpython-git-ee763e2acc469fa2f423440517b9bc227fbbe79c.tar.gz |
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 b3989e52a8..d00a51324a 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -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 |