Skip to content

Conversation

@koubaa
Copy link
Contributor

@koubaa koubaa commented Jan 12, 2026

HPy-defined types crashed with a segmentation fault on Python 3.13 when creating or instantiating types using the Universal ABI.

@koubaa koubaa changed the title add test cases for issue #493 fix issue #493 Jan 12, 2026
@koubaa
Copy link
Contributor Author

koubaa commented Jan 13, 2026

@vstinner could you please review this?

Python 3.13 changed how type __dict__ is handled for heap types.
When using PyType_FromSpec, the Py_TPFLAGS_MANAGED_DICT flag is NOT
automatically inherited from object - it must be set explicitly.

Without this flag, creating instances of HPy types would crash in
PyObject_GC_New() because the GC system expects managed dict support.

Changes:
- ctx_type.c: Explicitly set Py_TPFLAGS_MANAGED_DICT | Py_TPFLAGS_HAVE_GC
  in create_slot_defs() on Python 3.13+
- autogen_hpyfunc_trampolines.h: Fix NOARGS trampoline to include required
  second parameter per CPython C API docs (METH_NOARGS requires 2 params)
Copy link
Contributor

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall change LGTM, but I'm not a HPy developer so I cannot properly review the change.

@paugier
Copy link
Contributor

paugier commented Jan 14, 2026

@koubaa

Note that HPy does not support Python 3.13 (see #490).

@koubaa
Copy link
Contributor Author

koubaa commented Jan 14, 2026

@koubaa

Note that HPy does not support Python 3.13 (see #490).

Understood, this fixes some of the issues for python3.13, this doesn't attempt to support it fully

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

Successfully merging this pull request may close these issues.

3 participants