STINNER Victor <victor.stin...@haypocalc.com> added the comment: > I just looked at the code for PyFloat_AsDouble and it checks for NULL pointers
It's just a little help for developers: it will raise the ugly TypeError("bad argument type for built-in operation") and returns -1. It's never a good idea to pass NULL to a function of the Python C API. I think that most (or all?) functions will fail. > IMHO, the C-API documentation lacks information on how it behaves > in error conditions (this might be a bit over generalized). I didn't read the documentation, but you HAVE TO always check the result of a Python function. If the function returns a PyObject*, you have to check that the result is not NULL. The same rule applies for Pyxxx_AsXxx(): you also have to check the result (the error value depends on the function). Eg. PyInt_AsLong() returns -1 on error: use (result == -1) && PyErr_Occured()) in the caller to detect an error. ---------- nosy: +haypo _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8113> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com