diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-07-01 21:58:22 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-07-01 21:58:22 (GMT) |
commit | d09413012cb6b03fdae1439eaacc6076ce09f7b7 (patch) | |
tree | fb5203b5a4042d60042c89ce8a5c88e19daceb42 /Python/getargs.c | |
parent | 8934fc26c17f6a24d3643e1d4cce6e7ec341e92f (diff) | |
download | cpython-d09413012cb6b03fdae1439eaacc6076ce09f7b7.zip cpython-d09413012cb6b03fdae1439eaacc6076ce09f7b7.tar.gz cpython-d09413012cb6b03fdae1439eaacc6076ce09f7b7.tar.bz2 |
Revert r56044 (which changed the %c format specifier to accept a
unicode char into an int variable) and add %C which does this.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 1730bff..ce1fef7 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -761,6 +761,19 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, #endif /* WITHOUT_COMPLEX */ case 'c': {/* char */ + 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 < 256", arg, msgbuf, bufsize); + break; + } + + case 'C': {/* unicode char */ int *p = va_arg(*p_va, int *); if (PyString_Check(arg) && PyString_Size(arg) == 1) *p = PyString_AS_STRING(arg)[0]; |