Skip to content

Commit

Permalink
use PyErr_WarnEx instead of PyErr_WarnFormat since the latter is not …
Browse files Browse the repository at this point in the history
…available on all build platforms
  • Loading branch information
bendavid committed Mar 21, 2023
1 parent 26d6809 commit 4e29a95
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
PyObject* pymeth =
CPPOverload_Type.tp_descr_get(pyol, bNeedsRebind ? fSelf : nullptr, (PyObject*)&CPPOverload_Type);
Py_DECREF(pyol);
bool empty = diagnostics.str().find_first_not_of(' ') == diagnostics.str().npos;
if (!empty) {
PyErr_WarnFormat(PyExc_Warning, 1, "Compiler warnings during instantiation of \"%s(%s)\"\n%s", fname.c_str(),
proto.c_str(), diagnostics.str().c_str());
// check if diagnostics contains only spaces since this can happen as a result of clang indenting
const bool emptydiag = diagnostics.str().find_first_not_of(' ') == diagnostics.str().npos;
if (!emptydiag) {
std::ostringstream warnmsg;
warnmsg << "Compiler warnings during instantiation of \"" << fname << "(" << proto << ")\"\n"
<< diagnostics.str();
PyErr_WarnEx(PyExc_Warning, warnmsg.str().c_str(), 1);
}
return pymeth;
}
Expand Down

0 comments on commit 4e29a95

Please sign in to comment.