[Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.7,2.8
Jeremy Hylton
python-dev@python.org
Thu, 31 Aug 2000 08:10:31 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv13569/Modules
Modified Files:
gcmodule.c
Log Message:
apply patch #101362 by Vladimir Marangozov
also initial static debug variable to 0
Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.7
retrieving revision 2.8
diff -C2 -r2.7 -r2.8
*** gcmodule.c 2000/08/06 22:45:30 2.7
--- gcmodule.c 2000/08/31 15:10:24 2.8
***************
*** 58,62 ****
DEBUG_INSTANCES | \
DEBUG_OBJECTS
! static int debug;
/* list of uncollectable objects */
--- 58,62 ----
DEBUG_INSTANCES | \
DEBUG_OBJECTS
! static int debug = 0;
/* list of uncollectable objects */
***************
*** 223,229 ****
PyGC_Head *next;
PyGC_Head *gc = unreachable->gc_next;
! static PyObject *delstr;
if (delstr == NULL) {
delstr = PyString_InternFromString("__del__");
}
for (; gc != unreachable; gc=next) {
--- 223,231 ----
PyGC_Head *next;
PyGC_Head *gc = unreachable->gc_next;
! static PyObject *delstr = NULL;
if (delstr == NULL) {
delstr = PyString_InternFromString("__del__");
+ if (delstr == NULL)
+ Py_FatalError("PyGC: can't initialize __del__ string");
}
for (; gc != unreachable; gc=next) {
***************
*** 269,275 ****
static void
! debug_instance(PyObject *output, char *msg, PyInstanceObject *inst)
{
- char buf[200];
char *cname;
/* be careful not to create new dictionaries */
--- 271,276 ----
static void
! debug_instance(char *msg, PyInstanceObject *inst)
{
char *cname;
/* be careful not to create new dictionaries */
***************
*** 279,296 ****
else
cname = "?";
! sprintf(buf, "gc: %s<%.100s instance at %p>\n", msg, cname, inst);
! PyFile_WriteString(buf, output);
}
static void
! debug_cycle(PyObject *output, char *msg, PyObject *op)
{
if ((debug & DEBUG_INSTANCES) && PyInstance_Check(op)) {
! debug_instance(output, msg, (PyInstanceObject *)op);
} else if (debug & DEBUG_OBJECTS) {
! char buf[200];
! sprintf(buf, "gc: %s<%.100s %p>\n", msg,
! op->ob_type->tp_name, op);
! PyFile_WriteString(buf, output);
}
}
--- 280,295 ----
else
cname = "?";
! PySys_WriteStderr("gc: %.100s <%.100s instance at %p>\n",
! msg, cname, inst);
}
static void
! debug_cycle(char *msg, PyObject *op)
{
if ((debug & DEBUG_INSTANCES) && PyInstance_Check(op)) {
! debug_instance(msg, (PyInstanceObject *)op);
} else if (debug & DEBUG_OBJECTS) {
! PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
! msg, op->ob_type->tp_name, op);
}
}
***************
*** 358,375 ****
PyGC_Head finalizers;
PyGC_Head *gc;
- PyObject *output = NULL;
- if (debug) {
- output = PySys_GetObject("stderr");
- }
if (debug & DEBUG_STATS) {
! char buf[100];
! sprintf(buf, "gc: collecting generation %d...\n", generation);
! PyFile_WriteString(buf,output);
! sprintf(buf, "gc: objects in each generation: %ld %ld %ld\n",
gc_list_size(&generation0),
gc_list_size(&generation1),
gc_list_size(&generation2));
- PyFile_WriteString(buf,output);
}
--- 357,369 ----
PyGC_Head finalizers;
PyGC_Head *gc;
if (debug & DEBUG_STATS) {
! PySys_WriteStderr(
! "gc: collecting generation %d...\n"
! "gc: objects in each generation: %ld %ld %ld\n",
! generation,
gc_list_size(&generation0),
gc_list_size(&generation1),
gc_list_size(&generation2));
}
***************
*** 409,414 ****
gc = gc->gc_next) {
m++;
! if (output != NULL && (debug & DEBUG_COLLECTABLE)) {
! debug_cycle(output, "collectable ", PyObject_FROM_GC(gc));
}
}
--- 403,408 ----
gc = gc->gc_next) {
m++;
! if (debug & DEBUG_COLLECTABLE) {
! debug_cycle("collectable", PyObject_FROM_GC(gc));
}
}
***************
*** 423,439 ****
gc = gc->gc_next) {
n++;
! if (output != NULL && (debug & DEBUG_UNCOLLECTABLE)) {
! debug_cycle(output, "uncollectable ", PyObject_FROM_GC(gc));
}
}
! if (output != NULL && (debug & DEBUG_STATS)) {
if (m == 0 && n == 0) {
! PyFile_WriteString("gc: done.\n", output);
} else {
! char buf[200];
! sprintf(buf,
! "gc: done, %ld unreachable, %ld uncollectable.\n",
! n+m, n);
! PyFile_WriteString(buf, output);
}
}
--- 417,431 ----
gc = gc->gc_next) {
n++;
! if (debug & DEBUG_UNCOLLECTABLE) {
! debug_cycle("uncollectable", PyObject_FROM_GC(gc));
}
}
! if (debug & DEBUG_STATS) {
if (m == 0 && n == 0) {
! PySys_WriteStderr("gc: done.\n");
} else {
! PySys_WriteStderr(
! "gc: done, %ld unreachable, %ld uncollectable.\n",
! n+m, n);
}
}
***************
*** 445,449 ****
allocated = 0;
- PyErr_Clear(); /* in case writing to sys.stderr failed */
return n+m;
}
--- 437,440 ----