Summary
annotations_to_strings in plugins/python/src/modulewrap.cpp handles Numba CFunc annotations through the callable's _sig attribute. In that branch, annotation_as_text(ret) and annotation_as_text(item) may return an empty string after a Python API failure, but the current flow appends the empty result and sets conversion_ok = true without checking whether a Python exception is pending.
Required change
Update the _sig annotation-processing path in annotations_to_strings to detect annotation-normalization failures before treating the signature as successfully converted:
- Check the result of normalizing the return annotation and every argument annotation.
- Check
PyErr_Occurred() as needed to distinguish a valid empty annotation string from a Python-error result.
- On normalization failure, return
false without populating invalid signature types or setting conversion_ok = true.
- Preserve the existing successful behavior for valid annotations, including intentionally empty annotation text when no Python error is pending.
Rationale
Continuing registration with invalid/empty signature types while a Python exception remains pending can cause misleading downstream validation behavior and obscures the original normalization failure.
Affected area
plugins/python/src/modulewrap.cpp
annotations_to_strings
- Numba
CFunc _sig annotation handling
Acceptance criteria
- A failure in
annotation_as_text for _sig.return_type or any _sig.args entry causes annotations_to_strings to return false.
- The originating Python exception remains available to the Python caller.
- Invalid/partial signature types are not added to the output vectors on failure.
- Valid
_sig annotations continue to register unchanged.
Backlinks
Summary
annotations_to_stringsinplugins/python/src/modulewrap.cpphandles NumbaCFuncannotations through the callable's_sigattribute. In that branch,annotation_as_text(ret)andannotation_as_text(item)may return an empty string after a Python API failure, but the current flow appends the empty result and setsconversion_ok = truewithout checking whether a Python exception is pending.Required change
Update the
_sigannotation-processing path inannotations_to_stringsto detect annotation-normalization failures before treating the signature as successfully converted:PyErr_Occurred()as needed to distinguish a valid empty annotation string from a Python-error result.falsewithout populating invalid signature types or settingconversion_ok = true.Rationale
Continuing registration with invalid/empty signature types while a Python exception remains pending can cause misleading downstream validation behavior and obscures the original normalization failure.
Affected area
plugins/python/src/modulewrap.cppannotations_to_stringsCFunc_sigannotation handlingAcceptance criteria
annotation_as_textfor_sig.return_typeor any_sig.argsentry causesannotations_to_stringsto returnfalse._sigannotations continue to register unchanged.Backlinks
readability-braces-around-statements#762: clang-tidy: resolvereadability-braces-around-statements#762readability-braces-around-statements#762 (comment)