Skip to content

Avoid non-string binding crashes in BoundFunctionWrapper calls - #369

Open
edsonsims wants to merge 1 commit into
GrahamDumpleton:developfrom
edsonsims:fix/non-string-bound-wrapper-binding
Open

edsonsims wants to merge 1 commit into
GrahamDumpleton:developfrom
edsonsims:fix/non-string-bound-wrapper-binding

Conversation

@edsonsims

Copy link
Copy Markdown

Fixes #368.

I guard the Unicode-only comparison in BoundFunctionWrapper call dispatch with PyUnicode_Check. Ordinary non-string values then use the existing fallback path, as they do in the pure Python implementation, while normal string bindings and disabled wrappers keep their current behavior.

The regression tests cover free functions and bound class methods with ordinary non-string bindings, unknown string bindings, and disabled wrappers. The change note credits the original report.

Validation on macOS arm64:

  • The reported reproducer exits with SIGSEGV on the original C extension and returns ok with the original pure Python implementation.
  • Focused candidate tests pass with both implementations: 4 tests / 16 subtests each.
  • just test passes all 24 matrix cells: Python 3.10–3.15, including 3.14t/3.15t, with pure Python, C enabled, and C disabled at runtime. The 3.15 interpreters tested were 3.15.0rc2.
  • just test-mypy passes all six configured target versions with the pinned mypy 1.20.1.

This branch has not been deployed

No deployments
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.

BoundFunctionWrapper segfaults when binding is not a string

1 participant