@@ -116,6 +116,7 @@ notify_context_watchers(PyThreadState *ts, PyContextEvent event, PyObject *ctx)
116
116
// The callbacks are registered on the interpreter, not on the thread, so
117
117
// the only way callbacks can know which thread changed is by calling the
118
118
// callbacks from the affected thread.
119
+ assert (ts != NULL );
119
120
assert (ts == _PyThreadState_GET ());
120
121
if (ctx == NULL ) {
121
122
// This will happen after exiting the last context in the stack, which
@@ -221,7 +222,7 @@ PyContext_Enter(PyObject *octx)
221
222
{
222
223
PyThreadState * ts = _PyThreadState_GET ();
223
224
assert (ts != NULL );
224
- if (_PyContext_Enter (ts , octx )) {
225
+ if (_PyContext_Enter (ts , octx ) < 0 ) {
225
226
return -1 ;
226
227
}
227
228
context_switched (ts );
@@ -263,7 +264,7 @@ PyContext_Exit(PyObject *octx)
263
264
{
264
265
PyThreadState * ts = _PyThreadState_GET ();
265
266
assert (ts != NULL );
266
- if (_PyContext_Exit (ts , octx )) {
267
+ if (_PyContext_Exit (ts , octx ) < 0 ) {
267
268
return -1 ;
268
269
}
269
270
context_switched (ts );
@@ -278,7 +279,7 @@ _PyContext_ExitThreadOwned(PyThreadState *ts)
278
279
while (ts -> context != NULL
279
280
&& PyContext_CheckExact (ts -> context )
280
281
&& ((PyContext * )ts -> context )-> ctx_owned_by_thread ) {
281
- if (_PyContext_Exit (ts , ts -> context )) {
282
+ if (_PyContext_Exit (ts , ts -> context ) < 0 ) {
282
283
// Exiting a context that is already known to be at the top of the
283
284
// stack cannot fail.
284
285
Py_UNREACHABLE ();
@@ -533,7 +534,7 @@ context_get(void)
533
534
assert (ts != NULL );
534
535
if (ts -> context == NULL ) {
535
536
PyContext * ctx = context_new_empty ();
536
- if (ctx == NULL || _PyContext_Enter (ts , (PyObject * )ctx )) {
537
+ if (ctx == NULL || _PyContext_Enter (ts , (PyObject * )ctx ) < 0 ) {
537
538
return NULL ;
538
539
}
539
540
ctx -> ctx_owned_by_thread = 1 ;
0 commit comments