summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-04 04:17:33 +0000
committerGuido van Rossum <guido@python.org>2007-05-04 04:17:33 +0000
commit09dc34fc9c51f37f94cd9030ab8760677b360396 (patch)
tree264fb2452e8f27b0852350b363916ff7be5770c5 /Python
parentf15a29f975bbdef6de0aa19a19b176d1baf8f5ab (diff)
downloadcpython-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')
-rw-r--r--Python/getargs.c6
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;
}