diff options
author | Armin Rigo <arigo@tunes.org> | 2020-09-15 07:47:42 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-09-15 07:47:42 +0200 |
commit | af21ee113f8f95fdf1e9947f16a1d61e0ab1bc63 (patch) | |
tree | 0785190eb7529e3b4eeb2fd5002443313c746225 /c | |
parent | d5702128462686b2de2712de803227547889663b (diff) | |
parent | e885fdcc35aaba254228bd10f33dc92ed6baf579 (diff) | |
download | cffi-af21ee113f8f95fdf1e9947f16a1d61e0ab1bc63.tar.gz |
update branch release-1.14 for 1.14.3
Diffstat (limited to 'c')
-rw-r--r-- | c/_cffi_backend.c | 6 | ||||
-rw-r--r-- | c/test_c.py | 26 |
2 files changed, 17 insertions, 15 deletions
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() |