Lisandro Dalcin wrote:
> On Sun, Sep 13, 2009 at 7:55 AM, Stefan Behnel wrote:
>> 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?

Sure.


>> 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?

Things like the encoding functions, for example, that convert between bytes
and unicode. Using str here would be wrong.

Plus, changing the argument/return value types from "object" to the right
types will allow Cython to do actual type checking.


>> 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.

Yes, I guess that's a similar case.

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

Reply via email to