[Python-Dev] py3k: accept unicode for 'c' and byte for 'C' in getarg?

Victor Stinner victor.stinner at haypocalc.com
Tue Mar 17 14:00:14 CET 2009


Le Tuesday 17 March 2009 13:52:16 Victor Stinner, vous avez écrit :
> I realised with the issue #3446 that getarg('c') (get a byte) accepts not
> only a byte string of 1 byte, but also an unicode string of 1 character (if
> the character code is in [0; 255]). I don't think that it's a good idea to
> accept unicode here. Example: b"x".center(5, "\xe9") should be a TypeError.
>
> The "C" format (get a character) has the opposite problem: it accepts both
> byte and unicode, whereas byte should be rejected. Example:
> mmap.write_byte('é') should be a TypeError.

I opened an issue (with a patch) for my request:
   http://bugs.python.org/issue5499

Note: except of the bytes.{center,ljust,rjust} tests, all other tests are ok. 
It should not break the standard library, but maybe 3rd party library.

-- 
Victor Stinner aka haypo
http://www.haypocalc.com/blog/


More information about the Python-Dev mailing list