On May 10, 2010, at 5:27 PM, Paul Harrison wrote:
> Hello,
>
> I found a problem in Cython 12.1 (with Python 2.6.1). If you try to
> compile the following:
>
> str1 = 'a'
> str2 = 'a\n'
>
> It produces the following code, which will not compile:
>
> static char __pyx_k__a[] = "a";
> static char __pyx_k__a
> [] = "a\n";
I thought C was whitespace agnostic. What compiler are you using? In
any case, it's probably a trivial fix.
> Also, I find I can no longer cast str to char* (again with Python
> 2.6.1). The documentation seems to indicate this should only be a
> problem in Python 3, or have I missed something?
Cython is super strict about this right now even if you're only using
Py2 (too strict in my opinion, but that's a whole can of worms there
that we're not going to re-visit at this time...) Cast to an object
first, i.e. if x is a str, do
char* s = <object>x
(Short of type checking, is there a good way to encode in 3.x and
still allow str in 2.x?) Also, you might consider whether it is worth
declaring your variable to be of type str--are you using this fact
anywhere?
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev