Python 2.2 __slots__ Bug?

Jonathan Hogg jonathan at onegoodidea.com
Fri Jun 28 05:21:25 EDT 2002


On 28/6/2002 4:47, in article mailman.1025236118.663.python-list at python.org,
"Tim Peters" <tim.one at comcast.net> wrote:

>> ...
>> I can't see an easy way to fix this without changing the way that the
>> "delete later" list is constructed.
> 
> Sometimes we just agree to pretend that we never saw the bug report <wink>.

Actually I think I just figured out an easy way to fix the problem.

I was thinking that if there had been a liberal sprinkling of dicts in the
chain then it wouldn't overflow. But there's no way of doing that from the
Python side of things.

Then it occurred to me that it could be done from the C side of things:

Surround the slots deallocation in 'subtype_dealloc' with Py_TRASHCAN type
macros with the modification that if the recursion limit is hit, we create a
new tuple and set its items to be the contents of the slots, then DECREF it,
set the slots to NULL, and continue. The tuple deallocating code will see
that the recursion limit has been hit and add itself to the delete later
list.

This has the effect of inserting a container into the chain every few items
which can take part in the stack unwinding and restarting magic.

Simple and effective, no?

If I want to have a go at this, should I just upload a patch to Sourceforge,
or should I email it to someone?

Jonathan




More information about the Python-list mailing list