Blender Git Commit Log

Git Commits -> Revision c7236ef

October 28, 2020, 08:39 (GMT)
Fix T81688: BPY_thread_save crashes with Python 3.9

Calling PyEval_ReleaseLock() was crashing with Python 3.9
because it accessed the NULL pointer set by PyThreadState_Swap().

This happened when calling ViewLayer.update() for example.

While the existing logic could be fixed by swapping the thread-state
back before calling PyEval_ReleaseLock(), this depends on functions
which are tagged to be removed by v4.0.

Replace use of deprecated functions by calling PyEval_SaveThread(),
instead of inlining the logic, using _PyThreadState_UncheckedGet()
to prevent Python aborting.

The call to PyEval_ThreadsInitialized has been removed
as threads are now initialized with Python.
This could be replaced with Py_IsInitialized() however it doesn't look
like this is necessary.

This is compatible with Python 3.7 & 3.9.

Commit Details:

Full Hash: c7236ef4f1da68978dbd1e9777b904fef8103138
Parent Commit: 0ff7d21
Committed By: Jeroen Bakker
Lines Changed: +4, -7

1 Modified Path:

/source/blender/python/generic/bpy_threads.c (+4, -7) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021