[issue8212] A tp_dealloc of a subclassed class cannot resurrect an object

Antoine Pitrou report at bugs.python.org
Mon Apr 16 23:39:27 CEST 2012

Antoine Pitrou <pitrou at free.fr> added the comment:

> static int
> _textiowrapper_clear(textio *self)
> {
>     if (self->ok && _PyIOBase_finalize((PyObject *) self) < 0)
>         return -1;
> This shows something scary:  During a GC run, it is possible to invoke
> the  "close()" method on a textio object.  This is dangerous, and
> probably not allowed at all.

How is it scary? This is not worse than invoking a __del__ method.

> Returning -1 from a tp_clear() slot has no particular meaning, and the
> return value appears to be ignored by gcmodule.c

I don't think this is a problem.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list