Python: assert Python start/end/reset are used properly
This commit is contained in:
@@ -329,6 +329,7 @@ static void pystatus_exit_on_error(const PyStatus &status)
|
||||
void BPY_python_start(bContext *C, int argc, const char **argv)
|
||||
{
|
||||
#ifndef WITH_PYTHON_MODULE
|
||||
BLI_assert_msg(Py_IsInitialized() == 0, "Python has already been initialized");
|
||||
|
||||
/* #PyPreConfig (early-configuration). */
|
||||
{
|
||||
@@ -552,6 +553,8 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
|
||||
|
||||
void BPY_python_end(const bool do_python_exit)
|
||||
{
|
||||
BLI_assert_msg(Py_IsInitialized() != 0, "Python must be initialized");
|
||||
|
||||
PyGILState_STATE gilstate;
|
||||
|
||||
/* Finalizing, no need to grab the state, except when we are a module. */
|
||||
@@ -612,6 +615,8 @@ void BPY_python_end(const bool do_python_exit)
|
||||
|
||||
void BPY_python_reset(bContext *C)
|
||||
{
|
||||
BLI_assert_msg(Py_IsInitialized() != 0, "Python must be initialized");
|
||||
|
||||
/* Unrelated security stuff. */
|
||||
G.f &= ~(G_FLAG_SCRIPT_AUTOEXEC_FAIL | G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET);
|
||||
G.autoexec_fail[0] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user