Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add checks after using pybind ensure() - #32267

Merged
ksunden merged 1 commit into
matplotlib:mainfrom
iccir:check-ensure
Sep 4, 2026
Merged

Add checks after using pybind ensure()#32267
ksunden merged 1 commit into
matplotlib:mainfrom
iccir:check-ensure

Conversation

@iccir

@iccir iccir commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

PR summary

Checks that the result of calling ensure() call is non-null.

Closes #32261

AI Disclosure

I used AI as a search engine to find pybind11 documentation.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • [N/A] New features and API changes have release notes
  • [N/A] Documentation complies with general and docstring guidelines

@iccir
iccir marked this pull request as ready for review August 30, 2026 18:30
Comment thread src/_image_wrapper.cpp
// Ensure input array is contiguous, regardless of dtype
input_array = py::array::ensure(input_array, py::array::c_style);
if (!input_array) {
throw std::invalid_argument("Input array could not be made C-contiguous");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is likely unnecessary. I couldn't figure out a way to make this ensure() return a null. That said, throwing an exception is better than crashing.

Comment thread src/_path_wrapper.cpp
@QuLogic QuLogic added this to the v3.11.2 milestone Sep 1, 2026
@ksunden
ksunden merged commit 296a581 into matplotlib:main Sep 4, 2026
41 of 42 checks passed
QuLogic added a commit that referenced this pull request Sep 5, 2026
…267-on-v3.11.x

Backport PR #32267 on branch v3.11.x (Add checks after using pybind ensure())
@iccir
iccir deleted the check-ensure branch September 7, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: count_bboxes_overlapping_bbox() segfaults on a malformed ragged bbox

3 participants