[2.7] bpo-31692: Add PYTHONSHOWALLOCCOUNT env var (GH-3927)

bpo-31692, bpo-19527:

* Add a new PYTHONSHOWALLOCCOUNT environment variable, similar to
  the Python 3 "-X showalloccount" option
* When Python is compiled with COUNT_ALLOCS, the new
  PYTHONSHOWALLOCCOUNT environment variable now has to be set to dump
  allocation counts into stderr on shutdown. Moreover, allocations
  statistics are now dumped into stderr rather than stdout.
* Add @test.support.requires_type_collecting decorator: skip test if
  COUNT_ALLOCS is defined
* Fix tests for COUNT_ALLOCS: decorate some methods with
  @requires_type_collecting
* test_sys.test_objecttypes(): update object type when COUNT_ALLOCS
  is defined
This commit is contained in:
Victor Stinner
2017-10-17 02:25:23 -07:00
committed by GitHub
parent 3c082a7fdb
commit 7b4ba62e38
10 changed files with 28 additions and 4 deletions

View File

@@ -488,7 +488,9 @@ Py_Finalize(void)
/* Debugging stuff */
#ifdef COUNT_ALLOCS
dump_counts(stdout);
if (Py_GETENV("PYTHONSHOWALLOCCOUNT")) {
dump_counts(stderr);
}
#endif
_PyDebug_PrintTotalRefs();