From 2071c4d3d8503b8ae9ccd623cec1163ec6732a91 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Thu, 6 Jul 2017 08:23:34 +0200 Subject: Fix a unit test. Only try to acquire the GIL if the Python interpreter is actually initialized, otherwise there'll be a segfault. --- srd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'srd.c') diff --git a/srd.c b/srd.c index efd1c8e..fbdbdab 100644 --- a/srd.c +++ b/srd.c @@ -271,7 +271,8 @@ SRD_API int srd_exit(void) * Acquire the GIL, otherwise Py_Finalize() might have issues. * Ignore the return value, we don't need it here. */ - (void)PyGILState_Ensure(); + if (Py_IsInitialized()) + (void)PyGILState_Ensure(); /* Py_Finalize() returns void, any finalization errors are ignored. */ Py_Finalize(); -- cgit v1.2.3-70-g09d2