Hi,

Robert Bradshaw wrote:
> I'm suggesting "abc" is a byte string when linked against Py2, and a  
> unicode string when linked against Py3. This way string literals from  
> the module have the same type as string literals in the ambient  
> python environment. There is no way to say that in the above proposal.

Admittedly, that's how the 2to3 tool behaves, but that's different as it works
on the source level. So once you have invested the work to port your code to
Py2.6 and appended all your byte string literals with a 'b', 2to3 will do the
right thing when porting your code to Py3.

So what you suggest is that users who want to port their Cython code to Py3
are required to append all their byte literals with 'b'? Then what would be so
bad in also requiring them to add the future import at the top of their source
file to be explicit about the requested semantics?

Remember, automatic conversion between the two is gone in Py3. Code that
currently assumes an equality of unicode strings and byte strings is
fundamentally broken, beyond the simple printing of strings. It cannot be
fixed by simply transmogrifying all byte strings into unicode strings. Plus,
what would you do about this kind of code:

    cdef char* s = _some_c_call()
    result = s + "abc"

There's no "automatic" way to heal this. People *will* have to invest work to
port their code.

Stefan

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

Reply via email to