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

[Exp PyROOT] Fall back to __repr__ in __str__ if cling returns an address

parent c1b52fde
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,13 @@ PyObject *ClingPrintValue(CPPInstance *self) ...@@ -27,7 +27,13 @@ PyObject *ClingPrintValue(CPPInstance *self)
{ {
const std::string className = GetCppName(self); const std::string className = GetCppName(self);
auto printResult = gInterpreter->ToString(className.c_str(), self->GetObject()); 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());
}
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
......
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