Call PyErr_Clear()
instead of PyErr_Restore()
in py_get_attr_impl(silent = TRUE)
#1560
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.
This is a workaround for an issue encountered on Windows, where calling
py_get_attr(silent = TRUE)
raised an exception.https://github.com/rstudio/tensorflow/actions/runs/8439823909/job/23115333998?pr=594
Most likely, a previous Python expression had left an exception set but not raised, but it is not caught / checked until the guardrails in
_PyEval_EvalFrameDefault
checks the return value fromPyObject_GetAttrString()
.Ideally we would track down what was leaving an exception set, but this patch should result in a more reliable experience for users too.