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 Christian.Tismer
Recipients Christian.Tismer, Dormouse759, docs@python, loewis, ncoghlan, petr.viktorin, serhiy.storchaka
Date 2018-09-14.04:28:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1536899294.18.0.956365154283.issue26979@psf.upfronthosting.co.za>
In-reply-to
Content
Petr, Fine! PySide's problems are solved for now, no worries.
But as mentioned, there is more.


Problem 1)
----------

There is another thing that gives problems:

When creating types which have fields "behind" the normal type fields,
PySide had explicit structs that contained PyHeaptypeObject explicitly,
plus the extra fields.

We changed that into a normal PyType declaration (opaque) and a pointer
expression that dynamically computed the offset.

For that, we needed sizeof(PyType_Type). Ok, that could be solved by Python 
code, but this "trick" is not so obvious and should be documented, or
a variable should be provided that gives the heap type size, dynamically.


Problem 2)
----------

Harder is this:

For some operations, we needed access to fields of normal types, for instance the
tp_new field of PyType_Type. That is not possible, although it would be easy:

PyType_GetSlot forbids access to normal types, rigorously.
But concerning the "normal" type fields, those which are not indirections,
it would cost nothing to allow this for normal types.

This uses a property of types which has not explicitly been used:

* All types have the same basic structure *

That means, we can allow access to all "tp_" fields with simply changing a check
in PyType_GetSlot.

I'm not sure if that information should be made official. May be it should be hidden
and PyType_GetSlot should be made more complicated. But the proposed change comes
at no cost. And the prefixes like "nb_" or "sq_" are still visible, so I don't
think there was an intent to make type structures completely opaque?

For PySide, it was crucial to use that information to compute the offset of
certain fields of normal types, which is a bit of a Pep 384 breach.
We wrote code that verifies that these assumptions are all valid, but I would be 
happy to remove that and revert to only using PyType_GetSlot.

Please let me know if I can help with something!

Cheers - Chris
History
Date User Action Args
2018-09-14 04:28:14Christian.Tismersetrecipients: + Christian.Tismer, loewis, ncoghlan, petr.viktorin, docs@python, serhiy.storchaka, Dormouse759
2018-09-14 04:28:14Christian.Tismersetmessageid: <1536899294.18.0.956365154283.issue26979@psf.upfronthosting.co.za>
2018-09-14 04:28:14Christian.Tismerlinkissue26979 messages
2018-09-14 04:28:13Christian.Tismercreate