Issue #29073: bytearray formatting no longer truncates on first null byte.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 6d4c6a1..3fad6d8 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -283,13 +283,15 @@
{
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);