bpo-37729: gc: write stats at once (GH-15050)

gc used several PySys_WriteStderr() calls to write stats.
It caused stats mixed up when stderr is shared by multiple
processes like this:

  gc: collecting generation 2...
  gc: objects in each generation: 0 0gc: collecting generation 2...
  gc: objects in each generation: 0 0 126077 126077
  gc: objects in permanent generation: 0

  gc: objects in permanent generation: 0
  gc: done, 112575 unreachable, 0 uncollectablegc: done, 112575 unreachable, 0 uncollectable, 0.2223s elapsed
  , 0.2344s elapsed
(cherry picked from commit bf8162c8c45338470bbe487c8769bba20bde66c2)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 file changed