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

Replace "Unknown internal error occurred" with a more helpful message. #3982

Merged
merged 1 commit into from
May 31, 2022

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented May 30, 2022

Description

This PR extracts one particular pair of related behavior changes from PR #1895, to make the development history easier to follow.

  • For the public error_already_set, the usual net observable behavior change is simply a changed message; see changes in test_exceptions.py. Internally the detour through an artificially generated Python exception is eliminated, a std::runtime_error is thrown immediately from the error_already_set constructor. The rationale is that the root issue is obviously a C++ coding error.

  • The non-public detail::error_string() no longer has the surprising side-effect of setting an "Unknown internal error occurred" Python RuntimeError if the Python error indicator is not actually set when the function is called. A std::runtime_error is thrown instead. Again, the rationale is that the root issue is obviously a C++ coding error.

The source code comments are updated to reflect the behavior changes. While at it, existing behavior & limitations are more fully documented.

Note that these behavior changes passed Google-global testing via PR #1895, without any adjustments to user code. The main benefit of this PR is to improve the development experience (debugging).

Suggested changelog entry:

The behavior or ``error_already_set`` was made safer and the highly opaque "Unknown internal error occurred" message was replaced with a more helpful message.

@rwgk rwgk marked this pull request as ready for review May 30, 2022 20:18
@rwgk rwgk requested review from Skylion007 and henryiii May 30, 2022 20:18
@rwgk rwgk merged commit b24c5ed into pybind:master May 31, 2022
@rwgk rwgk deleted the unknown_error_is_known_error branch May 31, 2022 18:54
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label May 31, 2022
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Jul 7, 2022
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.

3 participants