]> sigrok.org Git - libsigrokdecode.git/commitdiff
Fix a unit test.
authorUwe Hermann <redacted>
Thu, 6 Jul 2017 06:23:34 +0000 (08:23 +0200)
committerUwe Hermann <redacted>
Thu, 6 Jul 2017 09:25:24 +0000 (11:25 +0200)
Only try to acquire the GIL if the Python interpreter is actually
initialized, otherwise there'll be a segfault.

srd.c

diff --git a/srd.c b/srd.c
index efd1c8ef4275f82840035e2171a5b5ff5710f1ed..fbdbdab888b1bb72a6fe32f57a00e4eaa62496da 100644 (file)
--- 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();