Skip to content
Snippets Groups Projects
Commit 7b8dd328 authored by Enric Tejedor Saavedra's avatar Enric Tejedor Saavedra
Browse files

[PyROOT] Py3: Clear Python error before getting attribute

In Python3, if an error is set (e.g. because we tried to get an
attribute that does not exist from an object), any subsequent
get attribute operation will fail, even if the attribute is
present. Clearing the error after the first (failed) attribute
get solves the problem.
parent 63255ca5
No related branches found
No related tags found
No related merge requests found
......@@ -276,7 +276,10 @@ namespace {
// still here? try instantiating methods
PyObject* clName = PyObject_GetAttr( pytmpl->fPyClass, PyStrings::gCppName );
if ( ! clName ) clName = PyObject_GetAttr( pytmpl->fPyClass, PyStrings::gName );
if (!clName) {
PyErr_Clear();
clName = PyObject_GetAttr(pytmpl->fPyClass, PyStrings::gName);
}
auto clNameStr = std::string(PyROOT_PyUnicode_AsString(clName));
if (clNameStr == "_global_cpp")
clNameStr = ""; // global namespace
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment