Skip to content

Commit 4c087a4

Browse files
committed
test_capi: Replace _Py_OPAQUE_PYOBJECT by Py_TARGET_ABI3T
1 parent dc8d4b8 commit 4c087a4

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

Lib/test/test_cext/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def test_build(self):
3838
self.check_build('_test_cext')
3939

4040
def check_build(self, extension_name, std=None, limited=False,
41-
opaque_pyobject=False):
41+
abi3t=False):
4242
venv_dir = 'env'
4343
with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe:
4444
self._check_build(extension_name, python_exe,
4545
std=std, limited=limited,
46-
opaque_pyobject=opaque_pyobject)
46+
abi3t=abi3t)
4747

4848
def _check_build(self, extension_name, python_exe, std, limited,
49-
opaque_pyobject):
49+
abi3t):
5050
pkg_dir = 'pkg'
5151
os.mkdir(pkg_dir)
5252
shutil.copy(SETUP, os.path.join(pkg_dir, os.path.basename(SETUP)))
@@ -60,8 +60,8 @@ def run_cmd(operation, cmd):
6060
env['CPYTHON_TEST_STD'] = std
6161
if limited:
6262
env['CPYTHON_TEST_LIMITED'] = '1'
63-
if opaque_pyobject:
64-
env['CPYTHON_TEST_OPAQUE_PYOBJECT'] = '1'
63+
if abi3t:
64+
env['CPYTHON_TEST_ABI3T'] = '1'
6565
env['CPYTHON_TEST_EXT_NAME'] = extension_name
6666
env['TEST_INTERNAL_C_API'] = str(int(self.TEST_INTERNAL_C_API))
6767
if support.verbose:
@@ -116,10 +116,9 @@ def test_build_limited_c11(self):
116116
def test_build_c11(self):
117117
self.check_build('_test_c11_cext', std='c11')
118118

119-
def test_build_opaque_pyobject(self):
120-
# Test with _Py_OPAQUE_PYOBJECT
121-
self.check_build('_test_limited_opaque_cext', limited=True,
122-
opaque_pyobject=True)
119+
def test_build_abi3t(self):
120+
# Test with Py_TARGET_ABI3T
121+
self.check_build('_test_abi3t', abi3t=True)
123122

124123
@unittest.skipIf(support.MS_WINDOWS, "MSVC doesn't support /std:c99")
125124
def test_build_c99(self):

Lib/test/test_cext/setup.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def main():
5959
std = os.environ.get("CPYTHON_TEST_STD", "")
6060
module_name = os.environ["CPYTHON_TEST_EXT_NAME"]
6161
limited = bool(os.environ.get("CPYTHON_TEST_LIMITED", ""))
62-
opaque_pyobject = bool(os.environ.get("CPYTHON_TEST_OPAQUE_PYOBJECT", ""))
62+
abi3t = bool(os.environ.get("CPYTHON_TEST_ABI3T", ""))
6363
internal = bool(int(os.environ.get("TEST_INTERNAL_C_API", "0")))
6464

6565
sources = [SOURCE]
@@ -91,14 +91,12 @@ def main():
9191
# CC env var overrides sysconfig CC variable in setuptools
9292
os.environ['CC'] = cmd
9393

94-
# Define Py_LIMITED_API macro
94+
# Define opt-in macros
9595
if limited:
96-
version = sys.hexversion
97-
cflags.append(f'-DPy_LIMITED_API={version:#x}')
96+
cflags.append(f'-DPy_LIMITED_API={sys.hexversion:#x}')
9897

99-
# Define _Py_OPAQUE_PYOBJECT macro
100-
if opaque_pyobject:
101-
cflags.append(f'-D_Py_OPAQUE_PYOBJECT')
98+
if abi3t:
99+
cflags.append(f'-DPy_TARGET_ABI3T={sys.hexversion:#x}')
102100

103101
if internal:
104102
cflags.append('-DTEST_INTERNAL_C_API=1')

0 commit comments

Comments
 (0)