test_metaclass and `set_meta_data`: it seems to be operating on the wrong legacy class?
mattip opened this issue · comments
In test_metaclass
there is this code:
Line 1462 in f611473
It calls into this function:
Lines 244 to 254 in f611473
In legacy mode the macro DummyMeta_AsStruct
is converted into
__attribute__((unused))
static inline DummyMeta * DummyMeta_AsStruct(HPyContext *ctx, HPy h) {
return (DummyMeta *) _HPy_AsStruct_Legacy(ctx, h);
}
where _HPy_AsStruct_Legacy
for CPython is _h2py(h)
. But the h
in the test is the Dummy
type object, not the DummyMeta
type object, so doesn't _h2py(h)
return the Dummy
data struct (and not the DummyMeta
struct the test is expecting? In universal mode, DummyMeta_AsStruct
calls _HPy_AsStruct_Type
, which I wrote as obj = handles.deref(h); type = type(obj); return dataptr(type)
so that it will return the DummyMeta
struct, but I don't know what to do for _HPy_AsStruct_Legacy
.
I had a bug in the PyPy implementation, and now things work. I am still not sure how.