Replace "Unknown internal error occurred" with a more helpful message. #3982
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
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, astd::runtime_error
is thrown immediately from theerror_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" PythonRuntimeError
if the Python error indicator is not actually set when the function is called. Astd::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.