GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — FIX: Inverted PyErr_Occurred check in enum type caster (_enums.h) by beelauuu · Pull Request #31556 · matplotlib/matplotlib

Conversation

@beelauuu

@beelauuu beelauuu commented Apr 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PR summary

Fix an inverted error-check in the pybind11 enum type caster in src/_enums.h. PyLong_AsLong signals failure by returning -1 and setting a Python exception. The correct way to check for failure should be: return !(ival == -1 && PyErr_Occurred());

Part of #31424

this is my first PR here; I just wanted to get the flow down of contributing here before making any larger changes :)

AI Disclosure

I used Claude Code to help understand the codebase. The fix itself is a one-character change I applied.

PR checklist

  • [N/A] "closes #0000" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • [N/A ] New Features and API Changes are noted with a directive and release note
  • [N/A ] Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@beelauuu
Fixed pybind11 conditional bug
6fd7445
QuLogic
QuLogic approved these changes Apr 23, 2026
View reviewed changes
@QuLogic QuLogic added this to the v3.11.0 milestone Apr 23, 2026
story645
story645 reviewed Apr 23, 2026
View reviewed changes
Comment thread src/_enums.h
value = decltype(value)(ival); \
Py_DECREF(tmp); \
return !(ival == -1 && !PyErr_Occurred()); \
return !(ival == -1 && PyErr_Occurred()); \

@story645 story645 Apr 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Kinda think return (ival !=-1 || !PyErr_Occurred()); is more readable - is there a reason we can't do this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ksunden ksunden modified the milestones: v3.11.0, v3.10.9 Apr 23, 2026
@ksunden
ksunden merged commit b39d992 into matplotlib:main Apr 23, 2026
41 of 42 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@meeseeksmachine meeseeksmachine mentioned this pull request Apr 23, 2026
Backport PR #31556 on branch v3.10.x (FIX: Inverted PyErr_Occurred check in enum type caster (_enums.h)) #31558
Merged
ksunden added a commit that referenced this pull request Apr 23, 2026
@ksunden @meeseeksmachine
Backport PR #31556: FIX: Inverted PyErr_Occurred check in enum type c…
a83faac
…aster (_enums.h)
ksunden added a commit that referenced this pull request Apr 23, 2026
@ksunden
Merge pull request #31558 from meeseeksmachine/auto-backport-of-pr-31…
1637932
…556-on-v3.10.x

Backport PR #31556 on branch v3.10.x (FIX: Inverted PyErr_Occurred check in enum type caster (_enums.h))
@ksunden ksunden mentioned this pull request Apr 24, 2026
merge up v3.10.9 #31560
Merged
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@story645 story645 story645 left review comments
@QuLogic QuLogic QuLogic approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

v3.10.9

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@beelauuu @QuLogic @story645 @ksunden
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.