Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error printing variables while debugging Cython

I'm trying to debug some Cython code with gdb that is wrapping C++ code to be called from Python. I followed the instructions in the documentation but I'm getting some errors while debugging that are unrelated to my code. Example:

(gdb) cy print some_variable
Python Exception <type 'exceptions.AttributeError'> 'PyDictObjectPtr' object has no attribute 'items':
Error occurred in Python: 'PyDictObjectPtr' object has no attribute 'items'

I'm also getting this one sometimes (usually after the first one):

Python Exception <class 'gdb.error'> There is no member named ob_sval.:
Error occurred in Python command: There is no member named ob_sval.

To debug the code I created an environment with Docker:

FROM debian

RUN apt-get update && apt-get upgrade -y && apt-get install -y \
  build-essential gdb-python2 python-dbg python-dev \
  python-pip python-numpy-dbg

RUN pip install cython pygments

CMD bash

I found two related posts in the cython-users google group but with no answer.

like image 402
hygorxaraujo Avatar asked Oct 04 '18 21:10

hygorxaraujo


1 Answers

An issue was finally opened in Cython (thanks @hygorxaraujo!) and it was identified as a defect:

https://github.com/cython/cython/issues/2699

Pull requests welcome!

like image 106
astrojuanlu Avatar answered Oct 12 '22 23:10

astrojuanlu