[Cython] [mailinglist] Re: problems with external data

Uwe Schmitt uschmitt at mineway.de
Fri Nov 14 13:10:59 CET 2008


Uwe Schmitt schrieb:
> Stefan Behnel schrieb:
>> Uwe Schmitt wrote:
>>> > I got a problem in the following situatino when wrapping
>>> > some c code:
>>> > 
>>> > file svdlib.h contains:
>>> > 
>>> >     extern char *SVDVersion;
>>> >     extern long SVDVerbosity;
>>> > 
>>> > file svlib.pyx begins with:
>>> > 
>>> >     cdef extern from "svdlib.h" :
>>> > 
>>> >         cdef extern long  SVDVerbosity
>>> >         cdef extern char * SVDVersion
>>> > 
>>> > 
>>> > If I study the generated C code, Cython
>>> > handles SVDVersion as a char*, but SVDVerbosity
>>> > as a PyObject*.
>>
>> Could you forward a section of your code and the corresponding generated C
>> code that shows this behaviour?
>>
>> Stefan 
>
> Good news: the problem disappeared after upgrading to Cython 0.10,

Bad news: the error occured again, I do not know what happens..

I'm using  "print SVDVersion"
and "print SVDVerbosity" which are translated as follows:

     /*
    "C:\cygwin\home\uschmitt\workspace_eclipse_ganymede\PySVDLIB\src\svdlibc.pyx":157
     *     cdef SMat As
     *
     *     SVDVerbosity = verbosity             # <<<<<<<<<<<<<<
     *     print SVDVerbosity
     *     print SVDVersion
     */
      Py_INCREF(__pyx_v_verbosity);
      Py_DECREF(__pyx_v_SVDVerbosity);
      __pyx_v_SVDVerbosity = __pyx_v_verbosity;

      /*
    "C:\cygwin\home\uschmitt\workspace_eclipse_ganymede\PySVDLIB\src\svdlibc.pyx":158
     *
     *     SVDVerbosity = verbosity
     *     print SVDVerbosity             # <<<<<<<<<<<<<<
     *     print SVDVersion
     *
     */
      __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename
    = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto
    __pyx_L1_error;}
      Py_INCREF(__pyx_v_SVDVerbosity);
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_SVDVerbosity);
      if (__Pyx_Print(((PyObject *)__pyx_1), 1) < 0) {__pyx_filename =
    __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto
    __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;

      /*
    "C:\cygwin\home\uschmitt\workspace_eclipse_ganymede\PySVDLIB\src\svdlibc.pyx":159
     *     SVDVerbosity = verbosity
     *     print SVDVerbosity
     *     print SVDVersion             # <<<<<<<<<<<<<<
     *
     *     if isinstance(A, scipy.sparse.spmatrix):
     */
      __pyx_1 = __Pyx_PyBytes_FromString(SVDVersion); if
    (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno =
    159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename
    = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto
    __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
      __pyx_1 = 0;
      if (__Pyx_Print(((PyObject *)__pyx_2), 1) < 0) {__pyx_filename =
    __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto
    __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

     

SVDVerbosity is declared as "PyObject *__pyx_v_SVDVerbosity;"
SVDVersion is not declared at all, which is the behavior I expected.

Greetings, Uwe


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/cython-dev/attachments/20081114/e5715364/attachment.htm 


More information about the Cython-dev mailing list