Skip to content

Commit b1cc62a

Browse files
authored
[3.12] gh-127906: Skip limited C API test_cext tests if Py_TRACE_REFS (#127993)
gh-127906: Skip limited C API test_cext tests if Py_TRACE_REFS Skip limited C API tests in test_cext and test_cppext if Python is configured with --with-trace-refs (if the Py_TRACE_REFS macro is defined).
1 parent 7f707fa commit b1cc62a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Lib/test/test_cext/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
import shlex
99
import shutil
1010
import subprocess
11+
import sys
1112
import unittest
1213
from test import support
1314

1415

1516
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.c')
1617
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
18+
Py_TRACE_REFS = hasattr(sys, 'getobjects')
1719

1820

1921
# With MSVC on a debug build, the linker fails with: cannot open file
@@ -47,6 +49,9 @@ def test_build_limited_c11(self):
4749
self.check_build('_test_limited_c11_cext', limited=True, std='c11')
4850

4951
def check_build(self, extension_name, std=None, limited=False):
52+
if limited and Py_TRACE_REFS:
53+
self.skipTest('Py_LIMITED_API is incompatible with Py_TRACE_REFS')
54+
5055
venv_dir = 'env'
5156
with support.setup_venv_with_pip_setuptools_wheel(venv_dir) as python_exe:
5257
self._check_build(extension_name, python_exe,

Lib/test/test_cppext/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import shlex
55
import shutil
66
import subprocess
7+
import sys
78
import unittest
89
from test import support
910

1011

1112
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
1213
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
14+
Py_TRACE_REFS = hasattr(sys, 'getobjects')
1315

1416

1517
# With MSVC on a debug build, the linker fails with: cannot open file
@@ -45,6 +47,9 @@ def test_build_limited(self):
4547
self.check_build('_testcppext_limited', limited=True)
4648

4749
def check_build(self, extension_name, std=None, limited=False):
50+
if limited and Py_TRACE_REFS:
51+
self.skipTest('Py_LIMITED_API is incompatible with Py_TRACE_REFS')
52+
4853
venv_dir = 'env'
4954
with support.setup_venv_with_pip_setuptools_wheel(venv_dir) as python_exe:
5055
self._check_build(extension_name, python_exe,

0 commit comments

Comments
 (0)