summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2020-09-15 07:47:42 +0200
committerArmin Rigo <arigo@tunes.org>2020-09-15 07:47:42 +0200
commitaf21ee113f8f95fdf1e9947f16a1d61e0ab1bc63 (patch)
tree0785190eb7529e3b4eeb2fd5002443313c746225
parentd5702128462686b2de2712de803227547889663b (diff)
parente885fdcc35aaba254228bd10f33dc92ed6baf579 (diff)
downloadcffi-af21ee113f8f95fdf1e9947f16a1d61e0ab1bc63.tar.gz
update branch release-1.14 for 1.14.3
-rw-r--r--.gitignore28
-rw-r--r--c/_cffi_backend.c6
-rw-r--r--c/test_c.py26
-rw-r--r--cffi/_embedding.h5
4 files changed, 22 insertions, 43 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 11ef5d2..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,28 +0,0 @@
-*~
-*.py[co]
-
-# Packages
-*.egg
-*.egg-info
-dist
-build
-eggs
-parts
-bin
-var
-sdist
-develop-eggs
-.installed.cfg
-
-# Installer logs
-pip-log.txt
-
-# Unit test / coverage reports
-.coverage
-.tox
-
-#Translations
-*.mo
-
-#Mr Developer
-.mr.developer.cfg
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index 8f4554f..5693eaf 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -6225,9 +6225,11 @@ static PyObject *prepare_callback_info_tuple(CTypeDescrObject *ct,
infotuple = Py_BuildValue("OOOO", ct, ob, py_rawerr, onerror_ob);
Py_DECREF(py_rawerr);
-#ifdef WITH_THREAD
+#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x03070000
/* We must setup the GIL here, in case the callback is invoked in
- some other non-Pythonic thread. This is the same as ctypes. */
+ some other non-Pythonic thread. This is the same as ctypes.
+ But PyEval_InitThreads() is always a no-op from CPython 3.7
+ (the call from ctypes was removed some time later I think). */
PyEval_InitThreads();
#endif
diff --git a/c/test_c.py b/c/test_c.py
index 9348afd..14d3f66 100644
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -3,17 +3,15 @@ import pytest
def _setup_path():
import os, sys
- if '__pypy__' in sys.builtin_module_names:
- global pytestmark
- pytestmark = pytest.mark.skip(
- "_cffi_backend.c: not tested on top of pypy, "
- "use pypy/module/_cffi_backend/test/ instead.")
- return False
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
- return True
-if _setup_path():
- from _cffi_backend import _testfunc, _get_types, _get_common_types
+_setup_path()
from _cffi_backend import *
+from _cffi_backend import _get_types, _get_common_types
+try:
+ from _cffi_backend import _testfunc
+except ImportError:
+ def _testfunc(num):
+ pytest.skip("_testunc() not available")
from _cffi_backend import __version__
# ____________________________________________________________
@@ -70,8 +68,10 @@ def find_and_load_library(name, flags=RTLD_NOW):
path = ctypes.util.find_library(name)
if path is None and name == 'c':
assert sys.platform == 'win32'
- assert sys.version_info >= (3,)
- py.test.skip("dlopen(None) cannot work on Windows with Python 3")
+ assert (sys.version_info >= (3,) or
+ '__pypy__' in sys.builtin_module_names)
+ py.test.skip("dlopen(None) cannot work on Windows "
+ "with PyPy or Python 3")
return load_library(path, flags)
def test_load_library():
@@ -2553,8 +2553,8 @@ def test_errno():
assert get_errno() == 95
def test_errno_callback():
- if globals().get('PY_DOT_PY') == '2.5':
- py.test.skip("cannot run this test on py.py with Python 2.5")
+ if globals().get('PY_DOT_PY'):
+ py.test.skip("cannot run this test on py.py (e.g. fails on Windows)")
set_errno(95)
def cb():
e = get_errno()
diff --git a/cffi/_embedding.h b/cffi/_embedding.h
index 207d683..456dc52 100644
--- a/cffi/_embedding.h
+++ b/cffi/_embedding.h
@@ -331,15 +331,20 @@ static int _cffi_carefully_make_gil(void)
/* call Py_InitializeEx() */
if (!Py_IsInitialized()) {
_cffi_py_initialize();
+#if PY_VERSION_HEX < 0x03070000
PyEval_InitThreads();
+#endif
PyEval_SaveThread(); /* release the GIL */
/* the returned tstate must be the one that has been stored into the
autoTLSkey by _PyGILState_Init() called from Py_Initialize(). */
}
else {
+#if PY_VERSION_HEX < 0x03070000
+ /* PyEval_InitThreads() is always a no-op from CPython 3.7 */
PyGILState_STATE state = PyGILState_Ensure();
PyEval_InitThreads();
PyGILState_Release(state);
+#endif
}
#ifdef WITH_THREAD