[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Objects object.c,2.114,2.115
Guido van Rossum
guido@digicool.com
Tue, 23 Jan 2001 22:22:14 -0500
> A few miscellaneous helpers.
>
> PyObject_Dump(): New function that is useful when debugging Python's C
> runtime. In something like gdb it can be a pain to get some useful
> information out of PyObject*'s. This function prints the str() of the
> object to stderr, along with the object's refcount and hex address.
>
> PyGC_Dump(): Similar to PyObject_Dump() but knows how to cast from the
> garbage collector prefix back to the PyObject* structure.
>
> [See Misc/gdbinit for some useful gdb hooks]
>
> none_dealloc(): Rather than SEGV if we accidentally decref None out of
> existance, we assign None's and NotImplemented's destructor slot to
> this function, which just calls abort().
Barry, since these are only gdb helpers, would it perhaps be better if
their names started with "_Py" to indicate that they aren't part of
the regular API? They violate an important rule: you shouldn't write
to stderr directly, but always to sys.stderr. (There's a helper
routines to write to stderr: PySys_WriteStderr().) I understand that
for the gdb helper it's important to use the real stderr, and I don't
object to having these functions present at all times (they're so
small), but I do think that we should make it clear (by a _Py name,
and also by a comment) that they should not be called!
--Guido van Rossum (home page: http://www.python.org/~guido/)