Skip to content

Small adjustement for c2py PR #26 - #30

Merged
parcollet merged 5 commits into
unstablefrom
legacy_v3
Aug 6, 2026
Merged

Small adjustement for c2py PR #26#30
parcollet merged 5 commits into
unstablefrom
legacy_v3

Conversation

@parcollet

Copy link
Copy Markdown
Collaborator

Add a check for a registration failure if a type is loaded twice

parcollet and others added 5 commits July 30, 2026 20:23
The module template emitted PyType_Ready and a raw conv_table insertion for
c2py::py_range in every module. Each module has its own wrap_pytype<py_range>
(internal linkage, and CPython dlopens extension modules RTLD_LOCAL, so the
copies are never merged), so every import overwrote the entry of the previous
one and modules disagreed on the c2py_range type.

Delegate both to c2py::register_internal_types, which keeps the first
registration. py_range is a c2py implementation detail and the template no
longer needs to know about it.

Requires c2py with register_internal_types.
The module init fetched the c2py table and threaded it through
register_internal_types and add_type_object_to_main, which now reach it
themselves. add_type_object_to_main also reports a failure now, so the init
returns NULL and the import fails with its exception, instead of returning the
module with an exception set and relying on CPython to notice.

Requires the matching c2py.
std::regex was only really used to strip the libc++/libstdc++ inline
namespaces from type names, where plain string search is enough.
The four other includes were unused.
str_t is not a c2py name. The generated code compiled only because c2py
declared that alias at global scope in serialization/as_tuple.hpp.
@parcollet
parcollet merged commit 66eee11 into unstable Aug 6, 2026
0 of 3 checks passed
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.

1 participant