[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
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 415d5eb..418481d 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -601,6 +601,7 @@
         del c1, c2, C, D
         gc.collect()
 
+    @test_support.requires_type_collecting
     def test_callback_in_cycle_resurrection(self):
         import gc