mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Change %c format specifier for PyArg_ParseTuple() so that it accepts
a unicode character (an int * must be passed as the argument). Change %c format specifier for Py_BuildValue() so that it outputs a unicode object. Fix datetime.datetime.isoformat(), so that it works if sep is a unicode character > U+00FF.
This commit is contained in:
parent
32a4c71419
commit
bc1f886170
4 changed files with 21 additions and 8 deletions
|
@ -761,15 +761,14 @@ 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 *);
|
||||
int *p = va_arg(*p_va, int *);
|
||||
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)
|
||||
PyUnicode_GET_SIZE(arg) == 1)
|
||||
*p = PyUnicode_AS_UNICODE(arg)[0];
|
||||
else
|
||||
return converterr("char < 256", arg, msgbuf, bufsize);
|
||||
return converterr("char", arg, msgbuf, bufsize);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue