[issue1303614] Bypassing __dict__ readonlyness

Guido van Rossum report at bugs.python.org
Thu Jan 24 18:05:15 CET 2008


Guido van Rossum added the comment:

On Jan 23, 2008 11:12 PM, Neal Norwitz <report at bugs.python.org> wrote:
>
> Neal Norwitz added the comment:
>
> I looked at Guido's latest deldict.diff patch--the one to
> Objects/object.c only.  It seems good.  I can't convince myself either
> way about the change to Objects/typeobject.c.  I can't think of a way
> to cause a problem.  It seems safer to use Py_CLEAR in this case
> though.

Here's my reasoning: the object whose dict is being cleared itself has
a refcount of zero at this point. So it is truly unreachable from
Python code. So I'm not going to submit that part of the change.

> There are several other uses of _PyObject_GetDictPtr in
> Objects/typeobject.c.  It was pretty much the same--I can't convince
> myself either way.  Can Py_VISIT cause any Python code to execute that
> might lead to a problem?

The answer lies in the gc module which does all the visiting. A quick
scan of all the traverse() calls there indicates that none of them
call back into Python -- not a DECREF in sight.

> The other uses of _PyObject_GetDictPtr in
> Objects/typeobject.c seemed safer.  Not a very useful review.

I reviewed those too and found them safe.

I'll submit the change now.

_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1303614>
_____________________________________


More information about the Python-bugs-list mailing list