diff options
author | Guido van Rossum <guido@python.org> | 2007-05-04 04:17:33 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-04 04:17:33 +0000 |
commit | 09dc34fc9c51f37f94cd9030ab8760677b360396 (patch) | |
tree | 264fb2452e8f27b0852350b363916ff7be5770c5 /Python/getargs.c | |
parent | f15a29f975bbdef6de0aa19a19b176d1baf8f5ab (diff) | |
download | cpython-git-09dc34fc9c51f37f94cd9030ab8760677b360396.tar.gz |
Compare and hash unicode objects like their UTF-8 representations.
Accept Unicode characters < 256 for 'c' format.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 7d55baeb38..f7a66048fb 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -764,8 +764,12 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, char *p = va_arg(*p_va, char *); if (PyString_Check(arg) && PyString_Size(arg) == 1) *p = PyString_AS_STRING(arg)[0]; + else if (PyUnicode_Check(arg) && + PyUnicode_GET_SIZE(arg) == 1 && + PyUnicode_AS_UNICODE(arg)[0] < 256) + *p = PyUnicode_AS_UNICODE(arg)[0]; else - return converterr("char", arg, msgbuf, bufsize); + return converterr("char < 256", arg, msgbuf, bufsize); break; } |