[Patches] Change to reference-dump procedure at shutdown

Mark Hammond mhammond@skippinet.com.au
Sun, 23 Apr 2000 14:57:38 +1000


This patch only affects debug builds with Py_TRACE_REFS defined.  This =
is the default for debug builds on Windows.

At shutdown, Python offers to dump the remaining references.  This =
upsets a few programs, such as debug COM servers, or any program that =
uses 'sys.executable' to launch a child-process.  The process never =
terminates, as it is waiting to find out if you want the references =
dumped.

Further, simply starting and closing the Python interpreter on Windows =
results in over 2000 references - its unlikely people want to print them =
that often :-)

The patch below only offers to dump the references if the environment =
variable PYTHONDUMPREFS is set.  Otherwise, it still prints the number =
of references, but immediately terminates.

If this patch is acceptable and it is felt this variable should be =
documented, let me know, and I will try and hunt down all the relevant =
places - but IMO, anyone who really needs these references dumped is =
likely to see this code :-)


diff -c -r2.92 pythonrun.c
*** pythonrun.c	2000/04/14 19:13:24	2.92
--- pythonrun.c	2000/04/23 04:49:05
***************
*** 242,248 ****
  #endif
 =20
  #ifdef Py_TRACE_REFS
! 	if (_Py_AskYesNo("Print left references?")) {
  		_Py_PrintReferences(stderr);
  	}
  #endif /* Py_TRACE_REFS */
--- 242,249 ----
  #endif
 =20
  #ifdef Py_TRACE_REFS
! 	if (getenv("PYTHONDUMPREFS") &&=20
! 	    _Py_AskYesNo("Print left references?")) {
  		_Py_PrintReferences(stderr);
  	}
  #endif /* Py_TRACE_REFS */

Release info:

I confirm that, to the best of my knowledge and belief, this =
contribution is free of any claims of third parties under copyright, =
patent or other rights or interests ("claims").  To the extent that I =
have any such claims, I hereby grant to CNRI a nonexclusive, =
irrevocable, royalty-free, worldwide license to reproduce, distribute, =
perform and/or display publicly, prepare derivative versions, and =
otherwise use this contribution as part of the Python software and its =
related documentation, or any derivative versions thereof, at no cost to =
CNRI or its licensed users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or =
not to incorporate this contribution in the Python software and its =
related documentation.  I further grant CNRI permission to use my name =
and other identifying information provided to CNRI by me for use in =
connection with the Python software and its related documentation.

Mark.