[Python-3000-checkins] r59462 - in python/branches/py3k: Doc/library/gc.rst Misc/NEWS Modules/gcmodule.c

amaury.forgeotdarc python-3000-checkins at python.org
Tue Dec 11 00:58:36 CET 2007


Author: amaury.forgeotdarc
Date: Tue Dec 11 00:58:35 2007
New Revision: 59462

Modified:
   python/branches/py3k/Doc/library/gc.rst
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/gcmodule.c
Log:
Minor cleanup in the gc module.
Removed gc.DEBUG_OBJECT: there is only one kind of objects.
Now gc.DEBUG_COLLECTABLE or gc.DEBUG_UNCOLLECTABLE can be used alone to print the 
corresponding list of objects.

Also removed a footnote about version 2.2, and a comment explaining some deleted code.


Modified: python/branches/py3k/Doc/library/gc.rst
==============================================================================
--- python/branches/py3k/Doc/library/gc.rst	(original)
+++ python/branches/py3k/Doc/library/gc.rst	Tue Dec 11 00:58:35 2007
@@ -131,7 +131,7 @@
 
    A list of objects which the collector found to be unreachable but could not be
    freed (uncollectable objects).  By default, this list contains only objects with
-   :meth:`__del__` methods. [#]_ Objects that have :meth:`__del__` methods and are
+   :meth:`__del__` methods. Objects that have :meth:`__del__` methods and are
    part of a reference cycle cause the entire reference cycle to be uncollectable,
    including objects not necessarily in the cycle but reachable only from it.
    Python doesn't collect such cycles automatically because, in general, it isn't
@@ -169,18 +169,6 @@
    the ``garbage`` list.
 
 
-.. data:: DEBUG_INSTANCES
-
-   When :const:`DEBUG_COLLECTABLE` or :const:`DEBUG_UNCOLLECTABLE` is set, print
-   information about instance objects found.
-
-
-.. data:: DEBUG_OBJECTS
-
-   When :const:`DEBUG_COLLECTABLE` or :const:`DEBUG_UNCOLLECTABLE` is set, print
-   information about objects other than instance objects found.
-
-
 .. data:: DEBUG_SAVEALL
 
    When set, all unreachable objects found will be appended to *garbage* rather
@@ -191,10 +179,6 @@
 
    The debugging flags necessary for the collector to print information about a
    leaking program (equal to ``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE |
-   DEBUG_INSTANCES | DEBUG_OBJECTS | DEBUG_SAVEALL``).
+   DEBUG_SAVEALL``).
 
 .. rubric:: Footnotes
-
-.. [#] Prior to Python 2.2, the list contained all instance objects in unreachable
-   cycles,  not only those with :meth:`__del__` methods.
-

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Tue Dec 11 00:58:35 2007
@@ -12,6 +12,10 @@
 Core and Builtins
 -----------------
 
+- Constants gc.DEBUG_OBJECT and gc.DEBUG_INSTANCE have been removed from the
+  gc module; gc.DEBUG_COLLECTABLE or gc.DEBUG_UNCOLLECTABLE are now enough to
+  print the corresponding list of objects considered by the garbage collector.
+
 - Issue #1580: New free format floating point representation based on 
   "Floating-Point Printer Sample Code", by Robert G. Burger. For example
   repr(11./5) now returns '2.2' instead of '2.2000000000000002'.

Modified: python/branches/py3k/Modules/gcmodule.c
==============================================================================
--- python/branches/py3k/Modules/gcmodule.c	(original)
+++ python/branches/py3k/Modules/gcmodule.c	Tue Dec 11 00:58:35 2007
@@ -66,11 +66,9 @@
 #define DEBUG_STATS		(1<<0) /* print collection statistics */
 #define DEBUG_COLLECTABLE	(1<<1) /* print collectable objects */
 #define DEBUG_UNCOLLECTABLE	(1<<2) /* print uncollectable objects */
-#define DEBUG_OBJECTS		(1<<4) /* print other objects */
 #define DEBUG_SAVEALL		(1<<5) /* save all garbage in gc.garbage */
 #define DEBUG_LEAK		DEBUG_COLLECTABLE | \
 				DEBUG_UNCOLLECTABLE | \
-				DEBUG_OBJECTS | \
 				DEBUG_SAVEALL
 static int debug;
 static PyObject *tmod = NULL;
@@ -398,13 +396,7 @@
 	}
 }
 
-/* Return true if object has a finalization method.
- * CAUTION:  An instance of an old-style class has to be checked for a
- *__del__ method, and earlier versions of this used to call PyObject_HasAttr,
- * which in turn could call the class's __getattr__ hook (if any).  That
- * could invoke arbitrary Python code, mutating the object graph in arbitrary
- * ways, and that was the source of some excruciatingly subtle bugs.
- */
+/* Return true if object has a finalization method. */
 static int
 has_finalizer(PyObject *op)
 {
@@ -627,10 +619,8 @@
 static void
 debug_cycle(char *msg, PyObject *op)
 {
-	if (debug & DEBUG_OBJECTS) {
-		PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
-				  msg, Py_Type(op)->tp_name, op);
-	}
+	PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
+			  msg, Py_Type(op)->tp_name, op);
 }
 
 /* Handle uncollectable garbage (cycles with finalizers, and stuff reachable
@@ -958,7 +948,6 @@
 "  DEBUG_STATS - Print statistics during collection.\n"
 "  DEBUG_COLLECTABLE - Print collectable objects found.\n"
 "  DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects found.\n"
-"  DEBUG_OBJECTS - Print objects other than instances.\n"
 "  DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n"
 "  DEBUG_LEAK - Debug leaking programs (everything but STATS).\n");
 
@@ -1219,7 +1208,6 @@
 	ADD_INT(DEBUG_STATS);
 	ADD_INT(DEBUG_COLLECTABLE);
 	ADD_INT(DEBUG_UNCOLLECTABLE);
-	ADD_INT(DEBUG_OBJECTS);
 	ADD_INT(DEBUG_SAVEALL);
 	ADD_INT(DEBUG_LEAK);
 #undef ADD_INT


More information about the Python-3000-checkins mailing list