MCPcopy Create free account
hub / github.com/mhammond/pywin32 / Python_do_int_callback

Function Python_do_int_callback

Pythonwin/win32uimodule.cpp:765–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

763#endif
764
765int Python_do_int_callback(PyObject *themeth, PyObject *thearglst)
766{
767 int retVal=INT_MAX; // an identifiable, but unlikely genuine value
768 // Was formerly UINT_MAX, which is actually -1 when placed in a signed int
769 PyObject *result = Python_do_callback(themeth, thearglst);
770 if (result==NULL)
771 return retVal;
772 if (result==Py_None) // allow for None==0
773 retVal = 0;
774 else{
775 retVal = PyInt_AsLong(result);
776 if (retVal == -1 && PyErr_Occurred()){
777 gui_print_error();
778 TRACE("Python_do_int_callback: callback had bad return type\n");
779 // Include the method in the error msg so the bad callback can actually be found
780 PyObject *meth_name=NULL, *err_static=NULL;
781 meth_name = PyObject_Repr(themeth);
782 if (meth_name == NULL)
783 gui_print_error(); // not much else we can do
784 err_static = PyWinCoreString_FromString(" - Callback must return an integer, or None");
785 if (err_static == NULL)
786 gui_print_error();
787 if (meth_name && err_static){
788 PyWinCoreString_Concat(&meth_name, err_static);
789 if (meth_name)
790 PyErr_SetObject(ui_module_error, meth_name);
791 gui_print_error();
792 }
793 Py_XDECREF(meth_name);
794 Py_XDECREF(err_static);
795 }
796 }
797#ifdef _DEBUG_HEAP // perform some diagnostics. May help trap reference errors.
798 if (_heapchk()!=_HEAPOK)
799 TRACE("**** Warning-heap corrupt after application callback ****\n");
800#endif
801 DODECREF(result);
802 return retVal;
803}
804int Python_callback(PyObject *method, WPARAM val)
805{
806 PyObject *meth = method;

Callers 1

Python_callbackFunction · 0.85

Calls 4

Python_do_callbackFunction · 0.85
gui_print_errorFunction · 0.85
PyWinCoreString_ConcatFunction · 0.70

Tested by

no test coverage detected