1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
From 916e7a23390fbca51ee4c649049af84d97a31d15 Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefanor@debian.org>
Date: Thu, 29 Dec 2016 22:15:35 +0100
Subject: We're interested in --with-pydebug not -d
Forwarded: https://bitbucket.org/cffi/cffi/commits/bd6789d993c6bf801843576963c98a37c5aed111
Patch-Name: pydebug-detection
---
cffi/setuptools_ext.py | 5 +++--
testing/cffi0/test_zintegration.py | 7 ++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/cffi/setuptools_ext.py b/cffi/setuptools_ext.py
index 211aebc..5b0f296 100644
--- a/cffi/setuptools_ext.py
+++ b/cffi/setuptools_ext.py
@@ -79,9 +79,10 @@ def _set_py_limited_api(Extension, kwds):
CPython itself should ignore the flag in a debugging version
(by not listing .abi3.so in the extensions it supports), but
it doesn't so far, creating troubles. That's why we check
- for "not sys.flags.debug". (http://bugs.python.org/issue28401)
+ for "not hasattr(sys, 'gettotalrefcount')" (the 2.7 compatible equivalent
+ of 'd' not in sys.abiflags). (http://bugs.python.org/issue28401)
"""
- if 'py_limited_api' not in kwds and not sys.flags.debug:
+ if 'py_limited_api' not in kwds and not hasattr(sys, 'gettotalrefcount'):
import setuptools
try:
setuptools_major_version = int(setuptools.__version__.partition('.')[0])
diff --git a/testing/cffi0/test_zintegration.py b/testing/cffi0/test_zintegration.py
index a1aeb39..d56dac2 100644
--- a/testing/cffi0/test_zintegration.py
+++ b/testing/cffi0/test_zintegration.py
@@ -156,20 +156,21 @@ class TestZIntegration(object):
except ImportError as e:
py.test.skip(str(e))
orig_version = setuptools.__version__
+ expecting_limited_api = not hasattr(sys, 'gettotalrefcount')
try:
setuptools.__version__ = '26.0.0'
from setuptools import Extension
kwds = _set_py_limited_api(Extension, {})
- assert kwds['py_limited_api'] == True
+ assert kwds.get('py_limited_api', False) == expecting_limited_api
setuptools.__version__ = '25.0'
kwds = _set_py_limited_api(Extension, {})
- assert not kwds
+ assert kwds.get('py_limited_api', False) == False
setuptools.__version__ = 'development'
kwds = _set_py_limited_api(Extension, {})
- assert kwds['py_limited_api'] == True
+ assert kwds.get('py_limited_api', False) == expecting_limited_api
finally:
setuptools.__version__ = orig_version
|