mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #18874: Implement the PEP 454 (tracemalloc)
This commit is contained in:
parent
0fb6072fad
commit
ed3b0bca3e
17 changed files with 4024 additions and 15 deletions
|
@ -2154,3 +2154,22 @@ def patch(test_instance, object_to_patch, attr_name, new_value):
|
|||
|
||||
# actually override the attribute
|
||||
setattr(object_to_patch, attr_name, new_value)
|
||||
|
||||
|
||||
def run_in_subinterp(code):
|
||||
"""
|
||||
Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc
|
||||
module is enabled.
|
||||
"""
|
||||
# Issue #10915, #15751: PyGILState_*() functions don't work with
|
||||
# sub-interpreters, the tracemalloc module uses these functions internally
|
||||
try:
|
||||
import tracemalloc
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
if tracemalloc.is_tracing():
|
||||
raise unittest.SkipTest("run_in_subinterp() cannot be used "
|
||||
"if tracemalloc module is tracing "
|
||||
"memory allocations")
|
||||
return _testcapi.run_in_subinterp(code)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue