Mercurial > cpython-lru_cache-weakref
diff Python/getargs.c @ 42139:1f7b66a9ffb0
Revert r56044 (which changed the %c format specifier to accept a
unicode char into an int variable) and add %C which does this.
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Sun, 01 Jul 2007 21:58:22 +0000 |
| parents | 4db0a0cc57ab |
| children | 85c22b4d4455 |
line wrap: on
line diff
--- a/Python/getargs.c Sat Jun 30 23:44:36 2007 +0000 +++ b/Python/getargs.c Sun Jul 01 21:58:22 2007 +0000 @@ -761,6 +761,19 @@ #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];
