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

Call PyErr_Clear() instead of PyErr_Restore() in py_get_attr_impl(silent = TRUE) #1560

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2763,21 +2763,16 @@ PyObjectRef py_get_attr_impl(PyObjectRef x,
{

ensure_python_initialized();
PyObject *attr;

if (silent) {
PyErrorScopeGuard _g;
PyObject *attr = PyObject_GetAttrString(x, key.c_str()); // new ref

attr = PyObject_GetAttrString(x, key.c_str());
if (attr == NULL)
if (attr == NULL) {
if (silent) {
PyErr_Clear();
return PyObjectRef(R_NilValue, false);

} else {

attr = PyObject_GetAttrString(x, key.c_str());
if (attr == NULL)
} else {
throw PythonException(py_fetch_error());

}
}

return py_ref(attr, x.convert());
Expand Down