diff --git a/bindings/pyroot_experimental/PyROOT/src/GenericPyz.cxx b/bindings/pyroot_experimental/PyROOT/src/GenericPyz.cxx index 601bdd16d0102918a94eeb8a04a7767a0eafc001..9e93e24ff9c619e028035e2943309cb616e885e9 100644 --- a/bindings/pyroot_experimental/PyROOT/src/GenericPyz.cxx +++ b/bindings/pyroot_experimental/PyROOT/src/GenericPyz.cxx @@ -27,7 +27,13 @@ PyObject *ClingPrintValue(CPPInstance *self) { const std::string className = GetCppName(self); auto printResult = gInterpreter->ToString(className.c_str(), self->GetObject()); - return CPyCppyy_PyUnicode_FromString(printResult.c_str()); + if (printResult.find("@0x") == 0) { + // Fall back to __repr__ if we just get an address from cling + auto method = PyObject_GetAttrString((PyObject*)self, "__repr__"); + return PyObject_CallObject(method, nullptr); + } else { + return CPyCppyy_PyUnicode_FromString(printResult.c_str()); + } } ////////////////////////////////////////////////////////////////////////////