diff options
author | Xiang Zhang <angwerzx@126.com> | 2017-09-14 02:33:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-14 02:33:26 (GMT) |
commit | c3e97d9d984130d1c2aceedc4dfcd603b3162688 (patch) | |
tree | 1c535a90448c1e7dd485eca3f2cfc9d4ea29b9fd /Modules/_struct.c | |
parent | 1b8f612e1800b6e58472113f4abe8ee7c31f4db7 (diff) | |
download | cpython-c3e97d9d984130d1c2aceedc4dfcd603b3162688.zip cpython-c3e97d9d984130d1c2aceedc4dfcd603b3162688.tar.gz cpython-c3e97d9d984130d1c2aceedc4dfcd603b3162688.tar.bz2 |
bpo-30246: fix several error messages which only mention bytes in struct (#1421)
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 9 |
1 files changed, 5 insertions, 4 deletions
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 @@ Struct___init___impl(PyStructObject *self, PyObject *format) 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 @@ Struct_unpack_impl(PyStructObject *self, Py_buffer *buffer) 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 @@ Struct_iter_unpack(PyStructObject *self, PyObject *buffer) } 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; |