Prevent crash in case Py_BuildValue() returns NULL
Avoid changing callback refcount in constructor/destructor
Since items of std::list are stored by-value, and implicit copy constructor of Callback doesn't incref, refcount of callback objects stored in the list is wrong
On top of that, destructor of Callback is called on exit, when the list is destroyed, but that happens only after Py_Finalize(), so it is already too late to decref (and decref on bogus PyObject can cause crash)
EVENT_COMMAND
as implementedPy_BuildValue()
returnsNULL
std::list
are stored by-value, and implicit copy constructor ofCallback
doesn't incref, refcount of callback objects stored in the list is wrongCallback
is called on exit, when the list is destroyed, but that happens only afterPy_Finalize()
, so it is already too late to decref (and decref on bogusPyObject
can cause crash)