@@ -1926,7 +1926,6 @@ Struct_unpack_impl(PyStructObject *self, Py_buffer *buffer)
19261926{
19271927 _structmodulestate * state = get_struct_state_structinst (self );
19281928 ENSURE_STRUCT_IS_READY (self );
1929- assert (self -> s_codes != NULL );
19301929 if (buffer -> len != self -> s_size ) {
19311930 PyErr_Format (state -> StructError ,
19321931 "unpack requires a buffer of %zd bytes" ,
@@ -1959,7 +1958,6 @@ Struct_unpack_from_impl(PyStructObject *self, Py_buffer *buffer,
19591958{
19601959 _structmodulestate * state = get_struct_state_structinst (self );
19611960 ENSURE_STRUCT_IS_READY (self );
1962- assert (self -> s_codes != NULL );
19631961
19641962 if (offset < 0 ) {
19651963 if (offset + self -> s_size > 0 ) {
@@ -2113,8 +2111,6 @@ Struct_iter_unpack_impl(PyStructObject *self, PyObject *buffer)
21132111 unpackiterobject * iter ;
21142112 ENSURE_STRUCT_IS_READY (self );
21152113
2116- assert (self -> s_codes != NULL );
2117-
21182114 if (self -> s_size == 0 ) {
21192115 PyErr_Format (state -> StructError ,
21202116 "cannot iteratively unpack with a struct of length 0" );
@@ -2255,7 +2251,6 @@ s_pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
22552251 soself = PyStructObject_CAST (self );
22562252 ENSURE_STRUCT_IS_READY (soself );
22572253 assert (PyStruct_Check (self , state ));
2258- assert (soself -> s_codes != NULL );
22592254 if (nargs != soself -> s_len )
22602255 {
22612256 PyErr_Format (state -> StructError ,
@@ -2299,7 +2294,6 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
22992294 soself = PyStructObject_CAST (self );
23002295 ENSURE_STRUCT_IS_READY (soself );
23012296 assert (PyStruct_Check (self , state ));
2302- assert (soself -> s_codes != NULL );
23032297 if (nargs != (soself -> s_len + 2 ))
23042298 {
23052299 if (nargs == 0 ) {
@@ -2386,6 +2380,7 @@ static PyObject *
23862380s_get_format (PyObject * op , void * Py_UNUSED (closure ))
23872381{
23882382 PyStructObject * self = PyStructObject_CAST (op );
2383+ ENSURE_STRUCT_IS_READY (self );
23892384 return PyUnicode_FromStringAndSize (PyBytes_AS_STRING (self -> s_format ),
23902385 PyBytes_GET_SIZE (self -> s_format ));
23912386}
0 commit comments