@@ -70,7 +70,6 @@ typedef struct {
7070 formatcode * s_codes ;
7171 PyObject * s_format ;
7272 PyObject * weakreflist ; /* List of weak references */
73- PyMutex mutex ; /* to prevent mutation during packing */
7473 bool ready ;
7574} PyStructObject ;
7675
@@ -1781,7 +1780,6 @@ s_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
17811780 s -> s_codes = NULL ;
17821781 s -> s_size = -1 ;
17831782 s -> s_len = -1 ;
1784- s -> mutex = (PyMutex ){0 };
17851783 s -> ready = false;
17861784 }
17871785 return self ;
@@ -1831,11 +1829,6 @@ Struct___init___impl(PyStructObject *self, PyObject *format)
18311829
18321830 Py_SETREF (self -> s_format , format );
18331831
1834- if (PyMutex_IsLocked (& self -> mutex )) {
1835- PyErr_SetString (PyExc_RuntimeError ,
1836- "Call Struct.__init__() in struct.pack()" );
1837- return -1 ;
1838- }
18391832 if (prepare_s (self )) {
18401833 return -1 ;
18411834 }
@@ -2174,7 +2167,7 @@ Struct_iter_unpack_impl(PyStructObject *self, PyObject *buffer)
21742167 * argument for where to start processing the arguments for packing, and a
21752168 * character buffer for writing the packed string. The caller must insure
21762169 * that the buffer may contain the required length for packing the arguments.
2177- * 0 is returned on success, - 1 is returned if there is an error.
2170+ * 0 is returned on success, 1 is returned if there is an error.
21782171 *
21792172 */
21802173static int
@@ -2298,13 +2291,10 @@ s_pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
22982291 char * buf = PyBytesWriter_GetData (writer );
22992292
23002293 /* Call the guts */
2301- PyMutex_Lock (& soself -> mutex );
23022294 if ( s_pack_internal (soself , args , 0 , buf , state ) != 0 ) {
2303- PyMutex_Unlock (& soself -> mutex );
23042295 PyBytesWriter_Discard (writer );
23052296 return NULL ;
23062297 }
2307- PyMutex_Unlock (& soself -> mutex );
23082298
23092299 return PyBytesWriter_FinishWithSize (writer , soself -> s_size );
23102300}
@@ -2406,13 +2396,11 @@ s_pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
24062396 }
24072397
24082398 /* Call the guts */
2409- PyMutex_Lock (& soself -> mutex );
24102399 if (s_pack_internal (soself , args , 2 , (char * )buffer .buf + offset , state ) != 0 ) {
2411- PyMutex_Unlock (& soself -> mutex );
24122400 PyBuffer_Release (& buffer );
24132401 return NULL ;
24142402 }
2415- PyMutex_Unlock ( & soself -> mutex );
2403+
24162404 PyBuffer_Release (& buffer );
24172405 Py_RETURN_NONE ;
24182406}
0 commit comments