File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -143,9 +143,13 @@ PyEventLoop PyEventLoop::_getLoopOnThread(PyThreadState *tstate) {
143
143
144
144
#if PY_VERSION_HEX >= 0x030d0000 // Python version is greater than 3.13
145
145
// The private `_PyThreadState_GetDict(tstate)` API gets removed in Python 3.13.
146
- // However, the fix below cannot be a perfect replacement since the public `PyThreadState_GetDict()` API can only get from the current thread.
146
+ // However, simply replacing it with `PyThreadState_GetDict()` does not work,
147
+ // since the public `PyThreadState_GetDict()` API can only get from the current thread.
147
148
// We need to somehow get the thread dictionary on the main thread instead of the current thread.
148
- PyObject *ts_dict = PyThreadState_GetDict ();
149
+ if (tstate == NULL ) {
150
+ return _loopNotFound ();
151
+ }
152
+ PyObject *ts_dict = tstate->dict ;
149
153
#elif PY_VERSION_HEX >= 0x03090000 // Python version is greater than 3.9
150
154
PyObject *ts_dict = _PyThreadState_GetDict (tstate); // borrowed reference
151
155
#else // Python 3.8
You can’t perform that action at this time.
0 commit comments