mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #12380: PyArg_ParseTuple now accepts a bytearray for the 'c' format.
As a side effect, this now allows the rjust, ljust and center methods of bytes and bytearray to accept a bytearray argument. Patch by Petri Lehtinen
This commit is contained in:
parent
66d2be8986
commit
906b88fb2a
6 changed files with 53 additions and 4 deletions
|
@ -828,6 +828,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
char *p = va_arg(*p_va, char *);
|
||||
if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1)
|
||||
*p = PyBytes_AS_STRING(arg)[0];
|
||||
else if (PyByteArray_Check(arg) && PyByteArray_Size(arg) == 1)
|
||||
*p = PyByteArray_AS_STRING(arg)[0];
|
||||
else
|
||||
return converterr("a byte string of length 1", arg, msgbuf, bufsize);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue