[issue24379] operator.subscript

Serhiy Storchaka report at bugs.python.org
Mon Nov 2 02:48:54 EST 2015


Serhiy Storchaka added the comment:

The are is a reference loop:

    global instance -> type -> method -> module globals -> global instance

Since an instance doesn't have GC head if __slots__ is empty, the loop can't be broken.

A workaround is to add a stub element to __slots__:

    __slots__ = ('__stub__',)

But operator.subscript is not the only class that causes a reference leak. Any class with empty __slots__ can create a loop and cause a leak.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24379>
_______________________________________


More information about the Python-bugs-list mailing list