Skip to content

error_converting + TYPE_ERR clobbers original exception (~15 sites) #531

@devdanzin

Description

@devdanzin

The error_converting macro checks ((x) == -1) && PyErr_Occurred(). When true, an exception is already active (e.g., OverflowError from PyArray_PyIntAsInt). The immediately following TYPE_ERR call overwrites it with a generic TypeError, discarding the more informative original exception.

Example: passing a too-large integer for window produces OverflowError: Python int too large to convert to C int, which is then replaced with TypeError: 'window' must be an integer.

Approximately 15 instances across all template files.

File(s): move_template.c:940-941,950-951,978-979,1000-1001 and similar in reduce_template.c, nonreduce_axis_template.c

Suggested fix: Either propagate the original exception directly (goto error;) or clear it intentionally before setting the new one (PyErr_Clear(); TYPE_ERR(...);).

See #518 for the complete report.

Found using cext-review-toolkit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions