Skip to content

[3.6] bpo-30246: fix several error messages which only mention bytes in struct (GH-1421) #3561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,8 @@ s_init(PyObject *self, PyObject *args, PyObject *kwds)
if (!PyBytes_Check(o_format)) {
Py_DECREF(o_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(o_format)->tp_name);
return -1;
}
Expand Down Expand Up @@ -1541,7 +1542,7 @@ s_unpack(PyObject *self, PyObject *input)
return NULL;
if (vbuf.len != soself->s_size) {
PyErr_Format(StructError,
"unpack requires a bytes object of length %zd",
"unpack requires a buffer of %zd bytes",
soself->s_size);
PyBuffer_Release(&vbuf);
return NULL;
Expand Down Expand Up @@ -1718,8 +1719,8 @@ s_iter_unpack(PyObject *_so, PyObject *input)
}
if (self->buf.len % so->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",
so->s_size);
Py_DECREF(self);
return NULL;
Expand Down