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.
Created on 2013年02月25日 16:24 by ronaldoussoren, last changed 2022年04月11日 14:57 by admin.
| Messages (5) | |||
|---|---|---|---|
| msg182959 - (view) | Author: Ronald Oussoren (ronaldoussoren) * (Python committer) | Date: 2013年02月25日 16:24 | |
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.
|
|||
| msg184637 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2013年03月19日 15:10 | |
Probably a duplicate of issue1173475. Do you want to work on the patch there? |
|||
| msg184640 - (view) | Author: Ronald Oussoren (ronaldoussoren) * (Python committer) | Date: 2013年03月19日 15:31 | |
You're right, this is a duplicate. |
|||
| msg185397 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2013年03月28日 01:21 | |
I closed the issue, but I didn't see that #1173475 was closed. Sorry, I reopened this issue again. |
|||
| msg237914 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2015年03月12日 05:27 | |
Encountered this when trying to add some fields to urllib.parse.SplitResult for Issue 22852. Issue 1173475 has a patch; I haven’t tried using it though. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:42 | admin | set | github: 61497 |
| 2015年03月12日 05:27:03 | martin.panter | set | nosy:
+ martin.panter messages: + msg237914 |
| 2013年03月28日 01:21:29 | vstinner | set | status: closed -> open nosy: + vstinner messages: + msg185397 |
| 2013年03月28日 01:20:40 | vstinner | set | status: open -> closed |
| 2013年03月19日 15:31:32 | ronaldoussoren | set | resolution: duplicate messages: + msg184640 type: behavior superseder: __slots__ for subclasses of variable length types stage: needs patch -> resolved |
| 2013年03月19日 15:10:31 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages: + msg184637 |
| 2013年02月25日 16:24:22 | ronaldoussoren | create | |