This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ronaldoussoren
Recipients ronaldoussoren
Date 2013-02-25.16:24:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361809462.28.0.456255129432.issue17295@psf.upfronthosting.co.za>
In-reply-to
Content
Currently a subclass of a PyVarObject (such as 'int') cannot use a non-empty slots, for example:

>>> class L (int):
...    __slots__ = ('a', 'b')
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: nonempty __slots__ not supported for subtype of 'int'
>>> 

However, subclasses that don't use __slots__ do have an implicit slot: the __dict__ value. Wouldn't it be possible to use the trick used for tp_dictoffset for slots as well, that is use negative values for the slot offsets and access them from the end of the object?

The major problem with an implementation is that PyMember_GetOne has a 'char*' argument instead of a 'PyObject*' one, but that's easily changed (PyMember_GetOne is currently only called in Object/descrobject.c and that call casts PyObject* to char*.  This would be an API change, but AFAIK PyMember_GetOne is not documented at the moment (and changing the argument type would be binary compatible).

I hope to work on a patch in the near future.
History
Date User Action Args
2013-02-25 16:24:22ronaldoussorensetrecipients: + ronaldoussoren
2013-02-25 16:24:22ronaldoussorensetmessageid: <1361809462.28.0.456255129432.issue17295@psf.upfronthosting.co.za>
2013-02-25 16:24:22ronaldoussorenlinkissue17295 messages
2013-02-25 16:24:21ronaldoussorencreate