hpy icon indicating copy to clipboard operation
hpy copied to clipboard

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

Open fangerer opened this issue 2 years ago • 1 comments

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 avatar Nov 24 '22 12:11 fangerer