On Nov 26, 1:43 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > k3xji wrote: > > On Nov 26, 1:34 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: > >> k3xji wrote: > >> > I am new to Python C API and finding it difficult to debug C > >> > extensions. So, basically I want to see the value of an integer value > >> > during the C API. Here is the code: > > >> > #define LAST_MIX_VAL 0xDEADBEEF > > >> > static PyObject * > >> > chash(PyObject *self, PyObject *args) > >> > { > >> > unsigned int key,result; //treat key like an usinged int. > >> > unsigned char a,b,c,d; > > >> > key = result = 0; > >> > if (!PyArg_ParseTuple(args, "i", &key)) > >> > return NULL; > > >> > printf("Key:%i\n",Py_BuildValue("i", key)); > >> > . > >> > . > >> > [...] > >> > - What is the preffered approach for these kind simple-debugging > >> > issue? > > >> If you want to simplify this kind of debugging as well as the general > >> code writing itself, consider using Cython. > > >>http://cython.org/ > > >> Apart from that, I'd use gdb for debugging these things. It does have a > >> learning curve, but in change gives you a lot more than just > >> "print-debugging". > > >> Stefan > > > OK. > > > How to use gdb? I am compiling the extension to a "pyd" file and > > importing it right now. So, I assume we need to, somehow load the > > extension dynamically for debugging? But how? > > You write a testscript that exposes the error you want to observe in the > C-layer. > > Then you do > > $ gdb python > # set args testscript.py > # break <some breakpoint, see how to enter that in gdb-docs> > # run > > That pretty much is it. You can't single-step python code this way, but you > can walk through C/C++-code. > > Diez
OK I see your point, I just expected an another way to do that from distutils itself. Thanks for the answer. By the way for simple print-debugging, below works right now, I forgot to try that fprintf(stderr,"%d", key); Thanks all again -- http://mail.python.org/mailman/listinfo/python-list