From e24983151ea5d64869efe30e45b8f1ed3ac8398a Mon Sep 17 00:00:00 2001 From: Pere Mato <pere.mato@cern.ch> Date: Fri, 18 Nov 2016 15:28:14 +0100 Subject: [PATCH] Fix for ROOT-8441 - template arguments deduction not working in Python --- bindings/pyroot/src/Utility.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bindings/pyroot/src/Utility.cxx b/bindings/pyroot/src/Utility.cxx index 7a90eca5c62..4ed77d5e82b 100644 --- a/bindings/pyroot/src/Utility.cxx +++ b/bindings/pyroot/src/Utility.cxx @@ -473,13 +473,15 @@ PyObject* PyROOT::Utility::BuildTemplateName( PyObject* pyname, PyObject* args, PyObject* tn = PyTuple_GET_ITEM( args, i ); if ( PyROOT_PyUnicode_Check( tn ) ) { PyROOT_PyUnicode_Append( &pyname, tn ); - } else if ( PyObject_HasAttr( tn, PyStrings::gCppName ) ) { - // this works for type objects - PyObject* tpName = PyObject_GetAttr( tn, PyStrings::gCppName ); - PyROOT_PyUnicode_AppendAndDel( &pyname, tpName ); } else if (PyObject_HasAttr( tn, PyStrings::gName ) ) { - PyObject* tpName = PyObject_GetAttr( tn, PyStrings::gName ); - // special case for strings + // __cppname__ provides a better name for C++ classes (namespaces) + PyObject* tpName; + if ( PyObject_HasAttr( tn, PyStrings::gCppName ) ) { + tpName = PyObject_GetAttr( tn, PyStrings::gCppName ); + } else { + tpName = PyObject_GetAttr( tn, PyStrings::gName ); + } + // special case for strings if ( strcmp( PyROOT_PyUnicode_AsString( tpName ), "str" ) == 0 ) { Py_DECREF( tpName ); tpName = PyROOT_PyUnicode_FromString( "std::string" ); -- GitLab