Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "factory sets error and returns nullptr" #4846

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Sep 12, 2023

Description

(The equivalent of this PR was merged as google/pybind11k#30064 on September 12, 2023.)

This is a very simple change in support of the PyCLIF-pybind11 integration work:

Merely an extra if to pre-empt TypeError: pybind11::init(): factory function returned nullptr. This allows the factory function to set a custom Python error instead.

Manually written factory functions could throw error_already_set() directly, but in the context of PyCLIF that is very difficult (compared to this very simple PR), because the factory function can be completely unaware of pybind11.

Suggested changelog entry:

Python errors set in constructor factory functions are no longer clobbered by a generic exception.

This is a very simple change in support of the PyCLIF-pybind11 integration work:

Merely an extra `if` to pre-empt `TypeError: pybind11::init(): factory function returned nullptr`. This allows the factory function to set a custom Python error instead.

Manually written factory functions could `throw error_already_set()` directly, but in the context of PyCLIF that is very difficult (compared to this very simple PR), because the factory function can be completely unaware of pybind11.
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.

None yet

1 participant