On Oct 27, 2008, at 5:50 PM, Jason Evans wrote:

> Using changeset a71073d1250c of cython-devel, the following program:
>
> ----------------
> cdef foo():
>      cdef str s
>      s = "hello"
> foo()
> ----------------
>
> causes the following warning when linking:
>
> lyken:~> cython foo.pyx
> lyken:~> gcc -shared -pthread -fPIC -fwrapv -Wall -fno-strict-aliasing
> -I/usr/local/python/dbg/include/python2.6 foo.c -ofoo.so
> foo.c: In function ‘__pyx_f_3foo_foo’:
> foo.c:212: warning: implicit declaration of function  
> ‘PyStr_CheckExact’
>
> and the following error when importing the resulting module:
>
> lyken:~> /usr/local/python/dbg/bin/python
> Python 2.6 (r26:66714, Oct 21 2008, 10:58:37)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import foo
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> ImportError: ./foo.so: undefined symbol: PyStr_CheckExact
> [26355 refs]
>>>>
>
> I've seen Cython generate similar bogus calls to PyStr_CheckExact
> several times today while coding, but in other cases I was able to  
> make
> the problem go away by adding type specifications so that  
> everything was
> clearly a str.  In this case, it looks like the compiler doesn't  
> realize
> that "hello" is a str (nor does it recognize str("hello") as a str).
>
> So, I think there are two problems:
>
> 1) Cython doesn't recognize string literals as str.
>
> 2) PyStr_CheckExact doesn't exist, at least for Python 2.6.  It does
> have PyString_CheckExact though.

Looks like it was (2), from Python 2.2+. Thanks for the fix.

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to