bpo-30246: fix several error messages which only mention bytes in struct (#1421)
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 69a1e99..04d7f8e 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1453,7 +1453,8 @@
if (!PyBytes_Check(format)) {
Py_DECREF(format);
PyErr_Format(PyExc_TypeError,
- "Struct() argument 1 must be a bytes object, not %.200s",
+ "Struct() argument 1 must be a str or bytes object, "
+ "not %.200s",
Py_TYPE(format)->tp_name);
return -1;
}
@@ -1535,7 +1536,7 @@
assert(self->s_codes != NULL);
if (buffer->len != self->s_size) {
PyErr_Format(StructError,
- "unpack requires a bytes object of length %zd",
+ "unpack requires a buffer of %zd bytes",
self->s_size);
return NULL;
}
@@ -1708,8 +1709,8 @@
}
if (iter->buf.len % self->s_size != 0) {
PyErr_Format(StructError,
- "iterative unpacking requires a bytes length "
- "multiple of %zd",
+ "iterative unpacking requires a buffer of "
+ "a multiple of %zd bytes",
self->s_size);
Py_DECREF(iter);
return NULL;