mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #29073: bytearray formatting no longer truncates on first null byte.
This commit is contained in:
parent
af9181a4f2
commit
c9ad8b7a23
3 changed files with 12 additions and 1 deletions
|
@ -283,13 +283,15 @@ bytearray_format(PyByteArrayObject *self, PyObject *args)
|
|||
{
|
||||
PyObject *bytes_in, *bytes_out, *res;
|
||||
char *bytestring;
|
||||
Py_ssize_t bytesize;
|
||||
|
||||
if (self == NULL || !PyByteArray_Check(self) || args == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
bytestring = PyByteArray_AS_STRING(self);
|
||||
bytes_in = PyBytes_FromString(bytestring);
|
||||
bytesize = PyByteArray_GET_SIZE(self);
|
||||
bytes_in = PyBytes_FromStringAndSize(bytestring, bytesize);
|
||||
if (bytes_in == NULL)
|
||||
return NULL;
|
||||
bytes_out = _PyBytes_Format(bytes_in, args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue