Skip to content

Commit fa82dda

Browse files
authored
[3.6] bpo-30246: fix several error messages which only mention bytes in struct (#3561)
1 parent 905e4ef commit fa82dda

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Modules/_struct.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,8 @@ s_init(PyObject *self, PyObject *args, PyObject *kwds)
14601460
if (!PyBytes_Check(o_format)) {
14611461
Py_DECREF(o_format);
14621462
PyErr_Format(PyExc_TypeError,
1463-
"Struct() argument 1 must be a bytes object, not %.200s",
1463+
"Struct() argument 1 must be a str or bytes object, "
1464+
"not %.200s",
14641465
Py_TYPE(o_format)->tp_name);
14651466
return -1;
14661467
}
@@ -1541,7 +1542,7 @@ s_unpack(PyObject *self, PyObject *input)
15411542
return NULL;
15421543
if (vbuf.len != soself->s_size) {
15431544
PyErr_Format(StructError,
1544-
"unpack requires a bytes object of length %zd",
1545+
"unpack requires a buffer of %zd bytes",
15451546
soself->s_size);
15461547
PyBuffer_Release(&vbuf);
15471548
return NULL;
@@ -1718,8 +1719,8 @@ s_iter_unpack(PyObject *_so, PyObject *input)
17181719
}
17191720
if (self->buf.len % so->s_size != 0) {
17201721
PyErr_Format(StructError,
1721-
"iterative unpacking requires a bytes length "
1722-
"multiple of %zd",
1722+
"iterative unpacking requires a buffer of "
1723+
"a multiple of %zd bytes",
17231724
so->s_size);
17241725
Py_DECREF(self);
17251726
return NULL;

0 commit comments

Comments
 (0)