summarylogtreecommitdiffstats
path: root/call_PyErr_Clear_if_no_such_attribute.patch
blob: c1c401562a01db23bdd69564d76739f752c71611 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/bindings/pyroot/src/Utility.cxx b/bindings/pyroot/src/Utility.cxx
index ffeae8e..d3ba063 100644
--- a/bindings/pyroot/src/Utility.cxx
+++ b/bindings/pyroot/src/Utility.cxx
@@ -219,8 +219,10 @@ Bool_t PyROOT::Utility::AddToClass(
 Bool_t PyROOT::Utility::AddToClass( PyObject* pyclass, const char* label, const char* func )
 {
    PyObject* pyfunc = PyObject_GetAttrString( pyclass, const_cast< char* >( func ) );
-   if ( ! pyfunc )
+   if ( ! pyfunc ) {
+      PyErr_Clear();
       return kFALSE;
+   }
 
    Bool_t isOk = PyObject_SetAttrString( pyclass, const_cast< char* >( label ), pyfunc ) == 0;