summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-28 07:54:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-28 07:54:22 (GMT)
commitc9ad8b7a2384f063dc0a99c652dccd9e7616e14e (patch)
treef9644fc5b99777b4667fe4dc035514d0ea9cedcd /Objects
parentaf9181a4f2498a0a722fcd9044b66106640cf4df (diff)
downloadcpython-c9ad8b7a2384f063dc0a99c652dccd9e7616e14e.zip
cpython-c9ad8b7a2384f063dc0a99c652dccd9e7616e14e.tar.gz
cpython-c9ad8b7a2384f063dc0a99c652dccd9e7616e14e.tar.bz2
Issue #29073: bytearray formatting no longer truncates on first null byte.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c4
1 files changed, 3 insertions, 1 deletions
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 @@ 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);