On Sun, Sep 13, 2009 at 7:55 AM, Stefan Behnel <[email protected]> wrote:
>
> Robert Bradshaw wrote:
>> I have a draft up at http://wiki.cython.org/enhancements/stringliterals
>> please all feel free to add and edit.
>
> Thanks, Robert.
>
> One thing I see missing is how this would be handled:
>
>        cdef str s = "some string"
>        cdef char* cs = s
>
> Should this simply result in a runtime error under Py3?
>
> Or would you forbid this and just raise a Cython compiler error (or
> warning), stating that "bytes" should be used instead? Although, this might
> actually appear inside of a Py2-only or try-except block, so I guess a
> warning would be the most we can do.
>

I'm inclined for a warning... and that warning would not be generated
in this case: "cdef char*cs = <bytes>s" , right?

> BTW, we shouldn't forget to adapt the .pxd files in Cython/Includes
> accordingly, so that they return either "bytes" or "unicode", but *never*
> "str" (or "object", if we know it's a string type).
>

Could you point to a couple of the C-API calls you are talking about?

> And "str", "bytes" and "unicode" wouldn't be assignable to each other,
> right? Or would you also leave that to runtime?
>

"bytes" <-> "unicode" (obviously?) would not be assignable, tough for
the case of "bytes" <-> "str" or "str" <-> "unicode", we could
generate similar Cython compile warnings as for the "[unsigned ]char
*" conversions.



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to