PyTuple_Check and other type check functions didn't check the NULL pointer
I was writing some C extensions for Python and use PyTupleType_Check extensively. I found that all the PySomeType_Check macros directly delegate the job to PyObject_TypeCheck(op, &PyType_Type). The PyObject_TypeCheck(op, &PyType_Type) is again a macro and defined as ((ob)->ob_type == (tp) || PyType_IsSubtype((ob)->ob_type, (tp))) in object.h. My questions is: is it necessary to check the null pointer in the macro or it's a job for the user? Semantically all the type check should report a false if a null pointer is encountered. I've already had the patch to this issue but I am not sure if I think this problem right. I don't know if there are some python core developers around but I would like to hear all opinions towards this. BTW, if the user didn't check null pointer before call the function, a segmentation fault might occur. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyTuple_Check and other type check functions didn't check the NULL pointer
On Mar 23, 8:24 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > NotGuru schrieb: > > > My questions is: is it necessary to check the null pointer in the > > macro or it's a job for the user? Semantically all the type check > > should report a false if a null pointer is encountered. I've already > > had the patch to this issue but I am not sure if I think this problem > > right. I don't know if there are some python core developers around > > but I would like to hear all opinions towards this. > > Unless stated otherwise no Py* or PY* function is NULL safe. You have to > check for NULL unless the docs *explicitly* say it's safe to call it > with a NULL argument. > > Christian Thank you Christian and John, I skipped Section 1.3 of that document, so shameful. ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: always getting 'None' return value from PyObject_CallObject
On Mar 23, 6:43 pm, Gal Aviel <[EMAIL PROTECTED]> wrote: > Hello all, > > Kinda desperate over here .. Any help would be greatly appreciated ! > > I'm trying to embed a Python interpreter inside a Verilog simulator as a > SystemVerilog DPI application. The python side implements a few SV exported > tasks. I've got a thin C shared library as the dpi app; all it does it get the > task arguments from the simulator and hand those to the Python side using the > Python C API. > > I followed '5.3 Pure Embedding' under Python 2.5 documentation very closely. > > When calling a function defined in my module, the function executes Ok - it > sees > the correct arguments being passed from C, and executes 100% - only the return > value is always 'None' (I tried returning a simple integer like '5' which > doesn't work). > I met similar problems before and I guess you can try to start from a minimum version that f takes no arguments. If your can't pass the right argument to f, it will always return none without any prompt. -- http://mail.python.org/mailman/listinfo/python-list
