+// To avoid recursion when an overridden virtual method wants to call the base
+// class version, temporarily set an attribute in the instance with the same
+// name as the method. Then the PyObject_GetAttr in the next findCallback
+// will return this attribute and the PyMethod_Check will fail.
+
+void wxPyCallbackHelper::setRecursionGuard(PyObject* method) const
+{
+ PyFunctionObject* func = (PyFunctionObject*)PyMethod_Function(method);
+ PyObject_SetAttr(m_self, func->func_name, Py_None);
+}
+
+void wxPyCallbackHelper::clearRecursionGuard(PyObject* method) const
+{
+ PyFunctionObject* func = (PyFunctionObject*)PyMethod_Function(method);
+ if (PyObject_HasAttr(m_self, func->func_name)) {
+ PyObject_DelAttr(m_self, func->func_name);
+ }
+}
+
+// bool wxPyCallbackHelper::hasRecursionGuard(PyObject* method) const
+// {
+// PyFunctionObject* func = (PyFunctionObject*)PyMethod_Function(method);
+// if (PyObject_HasAttr(m_self, func->func_name)) {
+// PyObject* attr = PyObject_GetAttr(m_self, func->func_name);
+// bool retval = (attr == Py_None);
+// Py_DECREF(attr);
+// return retval;
+// }
+// return false;
+// }
+
+