@@ -1453,7 +1453,8 @@ Struct___init___impl(PyStructObject *self, PyObject *format)
1453
1453
if (!PyBytes_Check (format )) {
1454
1454
Py_DECREF (format );
1455
1455
PyErr_Format (PyExc_TypeError ,
1456
- "Struct() argument 1 must be a bytes object, not %.200s" ,
1456
+ "Struct() argument 1 must be a str or bytes object, "
1457
+ "not %.200s" ,
1457
1458
Py_TYPE (format )-> tp_name );
1458
1459
return -1 ;
1459
1460
}
@@ -1535,7 +1536,7 @@ Struct_unpack_impl(PyStructObject *self, Py_buffer *buffer)
1535
1536
assert (self -> s_codes != NULL );
1536
1537
if (buffer -> len != self -> s_size ) {
1537
1538
PyErr_Format (StructError ,
1538
- "unpack requires a bytes object of length %zd" ,
1539
+ "unpack requires a buffer of %zd bytes " ,
1539
1540
self -> s_size );
1540
1541
return NULL ;
1541
1542
}
@@ -1708,8 +1709,8 @@ Struct_iter_unpack(PyStructObject *self, PyObject *buffer)
1708
1709
}
1709
1710
if (iter -> buf .len % self -> s_size != 0 ) {
1710
1711
PyErr_Format (StructError ,
1711
- "iterative unpacking requires a bytes length "
1712
- "multiple of %zd" ,
1712
+ "iterative unpacking requires a buffer of "
1713
+ "a multiple of %zd bytes " ,
1713
1714
self -> s_size );
1714
1715
Py_DECREF (iter );
1715
1716
return NULL ;
0 commit comments