Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous tests in test_hpytype_legacy.py #459

Open
mattip opened this issue Nov 29, 2023 · 0 comments
Open

Ambiguous tests in test_hpytype_legacy.py #459

mattip opened this issue Nov 29, 2023 · 0 comments

Comments

@mattip
Copy link
Contributor

mattip commented Nov 29, 2023

The code in test_htype.py has tests like

    def test_simple_type(self):
        mod = self.make_module("""
            static HPyType_Spec Dummy_spec = {
                .name = "mytest.Dummy",
                .itemsize = 0,
                .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE,
                @DEFAULT_SHAPE
            };

            @EXPORT_TYPE("Dummy", Dummy_spec)
            @INIT
        """)

When run in test_hpytype.py then @DEFAULT_SHAPE is an empty comment "/* default object shape */" and everything is fine. But when these tests are rerun in test_hpytype_legacy.py, then @DEFAULT_SHAPE becomes .builtin_shape = HPyType_BuiltinShape_Legacy.

As I understand the intention of using the legacy shape is that the type can be used via the C-API, so it needs to become a heap type object. But the preamble to add #include <Python.h> is missing, and the basicsize is 0 (not declared). I guess I can work around the missing include file somehow, but it is not clear to me if a type spec can declare legacy shape without declaring a basicsize. Thoughts? Should this Just Work (i.e. when creating a type from the spec, note the legacy flag and allocate a heap type object as the storage)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant