Repository navigation
fix: return None for null Eigen matrix pointers - #6184
Merged
Merged
Conversation
henryiii
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5635.
The dense Eigen caster passed null pointers to capsule creation or dereferenced them, depending on the return policy. Return
Nonebefore applying the policy, matching other pointer casters. The regression covers mutable and const matrix pointers with all seven return policies.Validation with Eigen 3.4.0:
bf21a6dfwith the regression tests added,python3 -m pytest /baseline/tests/test_eigen_matrix.py -k 'null_matrix and automatic and not reference' -qfails both cases withValueError: PyCapsule_New called with null pointer.python3 -m pytest /baseline/tests/test_eigen_matrix.py -qpasses all 46 tests.cmake --build /build --target check -j 6passes: 1,328 Python tests (48 skipped), standalone C++ tests, embedded-interpreter tests, cross-module RTTI tests, and six CMake integration checks.python -c "import os, pytest; dlls = os.add_dll_directory('C:/msys64/ucrt64/bin'); raise SystemExit(pytest.main(['../../tests/test_eigen_matrix.py', '-q']))"frombuild/tests.prek run --all-files --quietandgit diff --checkpass.Suggested changelog entry:
Nonewhen a bound function returns a null pointer to a dense Eigen matrix.