hpyproject / hpy

HPy: a better API for Python
https://hpyproject.org
MIT License
1.02k stars 52 forks source link

Properly handle pure HPy types extending from a custom legacy type. #380

Open fangerer opened 1 year ago

fangerer commented 1 year ago

This is related to issue #169 .

Although it is possible for pure types to extend any legacy type (in the sense that at the time of type creation, HPy won't raise an error), it is actually not supported. Using the <type_struct>_AsStruct function will most likely return the wrong pointer.

This is maybe something HPy should prevent by default. However, it might still make sense to allow it since one can use _HPyType_GetBuiltinShape to get the shape of the base type to determine if it is a legacy type and then it is possible to implement a custom *_AsStruct by manually adding the base's basicsize. Since that is pretty complicated and error prone, I think HPy should either disallow it or properly support it.

fangerer commented 1 year ago

I expect that this does not affect the ABI but just the implementation. So, I'm removing this from the ABI version 1 milestone.