@@ -144,17 +144,18 @@ type_lock_prevent_release(void)
144
144
PyThreadState * tstate = _PyThreadState_GET ();
145
145
uintptr_t * tagptr = & tstate -> critical_section ;
146
146
PyCriticalSection * c = (PyCriticalSection * )(* tagptr & ~_Py_CRITICAL_SECTION_MASK );
147
- if (c -> _cs_mutex == TYPE_LOCK ) {
147
+ if (!(* tagptr & _Py_CRITICAL_SECTION_TWO_MUTEXES )) {
148
+ assert (c -> _cs_mutex == TYPE_LOCK );
148
149
c -> _cs_mutex = NULL ;
149
150
}
150
151
else {
151
- assert (* tagptr & _Py_CRITICAL_SECTION_TWO_MUTEXES );
152
152
PyCriticalSection2 * c2 = (PyCriticalSection2 * )c ;
153
- if (c2 -> _cs_mutex2 == TYPE_LOCK ) {
154
- c2 -> _cs_mutex2 = NULL ;
155
- }
156
- else {
157
- assert (0 ); // TYPE_LOCK must be one of the mutexes
153
+ if (c -> _cs_mutex == TYPE_LOCK ) {
154
+ c -> _cs_mutex = c2 -> _cs_mutex2 ;
155
+ c2 -> _cs_mutex2 = NULL ;
156
+ } else {
157
+ assert (c2 -> _cs_mutex2 == TYPE_LOCK );
158
+ c2 -> _cs_mutex2 = NULL ;
158
159
}
159
160
}
160
161
}
@@ -165,18 +166,14 @@ type_lock_allow_release(void)
165
166
PyThreadState * tstate = _PyThreadState_GET ();
166
167
uintptr_t * tagptr = & tstate -> critical_section ;
167
168
PyCriticalSection * c = (PyCriticalSection * )(* tagptr & ~_Py_CRITICAL_SECTION_MASK );
168
- if (c -> _cs_mutex == NULL ) {
169
+ if (!(* tagptr & _Py_CRITICAL_SECTION_TWO_MUTEXES )) {
170
+ assert (c -> _cs_mutex == NULL );
169
171
c -> _cs_mutex = TYPE_LOCK ;
170
172
}
171
173
else {
172
- assert (* tagptr & _Py_CRITICAL_SECTION_TWO_MUTEXES );
173
174
PyCriticalSection2 * c2 = (PyCriticalSection2 * )c ;
174
- if (c2 -> _cs_mutex2 == NULL ) {
175
- c2 -> _cs_mutex2 = TYPE_LOCK ;
176
- }
177
- else {
178
- assert (0 );
179
- }
175
+ assert (c2 -> _cs_mutex2 == NULL );
176
+ c2 -> _cs_mutex2 = TYPE_LOCK ;
180
177
}
181
178
}
182
179
0 commit comments