summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-16 10:07:45 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-27 19:37:26 +0100
commit9c50887daa2b44251e77be8123c63df238034cf5 (patch)
tree35cf71dcdbe210cfe6800c6fe0731a49a18e2e94
parent01a2d5fe4c37a8403cc9411bd2ad61184616fab9 (diff)
downloadswig-9c50887daa2b44251e77be8123c63df238034cf5.tar.gz
Python 3.9 support
Remove PyEval_InitThreads() call for Python 3.7 and later as Python calls it automatically now. This removes a deprecation warning when using Python 3.9. https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
-rw-r--r--CHANGES.current4
-rw-r--r--Lib/python/pythreads.swg8
2 files changed, 10 insertions, 2 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 2d8037197..c1bac0667 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
+2020-08-16: wsfulton
+ [Python] Remove PyEval_InitThreads() call for Python 3.7 and later as Python calls
+ it automatically now. This removes a deprecation warning when using Python 3.9.
+
2020-08-15: wsfulton
[Python] All Python examples and tests are written to be Python 2 and Python 3
compatible, removing the need for 2to3 to run the examples or test-suite.
diff --git a/Lib/python/pythreads.swg b/Lib/python/pythreads.swg
index d8797e659..8d6c5ab49 100644
--- a/Lib/python/pythreads.swg
+++ b/Lib/python/pythreads.swg
@@ -8,8 +8,12 @@
# define SWIG_PYTHON_USE_GIL
# endif
# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
-# ifndef SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+# if PY_VERSION_HEX < 0x03070000
+# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# else
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# endif
# endif
# ifdef __cplusplus /* C++ code */
class SWIG_Python_Thread_Block {