gh-116417: Add _testlimitedcapi C extension (#116419)

Add a new C extension "_testlimitedcapi" which is only built with the
limited C API.

Move heaptype_relative.c and vectorcall_limited.c from
Modules/_testcapi/ to Modules/_testlimitedcapi/.

* configure: add _testlimitedcapi test extension.
* Update generate_stdlib_module_names.py.
* Update make check-c-globals.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
Victor Stinner 2024-03-07 19:31:12 +01:00 committed by GitHub
parent d9ccde28c4
commit d9bcdda39c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 394 additions and 109 deletions

View File

@ -1153,8 +1153,9 @@ def refcount_test(test):
def requires_limited_api(test):
try:
import _testcapi
import _testlimitedcapi
except ImportError:
return unittest.skip('needs _testcapi module')(test)
return unittest.skip('needs _testcapi and _testlimitedcapi modules')(test)
return test
def requires_specialization(test):

View File

@ -5,6 +5,10 @@ try:
import _testcapi
except ImportError:
_testcapi = None
try:
import _testlimitedcapi
except ImportError:
_testlimitedcapi = None
import struct
import collections
import itertools
@ -837,12 +841,12 @@ class TestPEP590(unittest.TestCase):
@requires_limited_api
def test_vectorcall_limited_incoming(self):
from _testcapi import pyobject_vectorcall
obj = _testcapi.LimitedVectorCallClass()
obj = _testlimitedcapi.LimitedVectorCallClass()
self.assertEqual(pyobject_vectorcall(obj, (), ()), "vectorcall called")
@requires_limited_api
def test_vectorcall_limited_outgoing(self):
from _testcapi import call_vectorcall
from _testlimitedcapi import call_vectorcall
args_captured = []
kwargs_captured = []
@ -858,7 +862,7 @@ class TestPEP590(unittest.TestCase):
@requires_limited_api
def test_vectorcall_limited_outgoing_method(self):
from _testcapi import call_vectorcall_method
from _testlimitedcapi import call_vectorcall_method
args_captured = []
kwargs_captured = []

View File

@ -47,6 +47,7 @@ except ModuleNotFoundError:
# Skip this test if the _testcapi module isn't available.
_testcapi = import_helper.import_module('_testcapi')
import _testlimitedcapi
import _testinternalcapi
@ -1124,7 +1125,7 @@ class TestHeapTypeRelative(unittest.TestCase):
# Test subclassing using "relative" basicsize, see PEP 697
def check(extra_base_size, extra_size):
Base, Sub, instance, data_ptr, data_offset, data_size = (
_testcapi.make_sized_heaptypes(
_testlimitedcapi.make_sized_heaptypes(
extra_base_size, -extra_size))
# no alignment shenanigans when inheriting directly
@ -1152,11 +1153,11 @@ class TestHeapTypeRelative(unittest.TestCase):
# we don't reserve (requested + alignment) or more data
self.assertLess(data_size - extra_size,
_testcapi.ALIGNOF_MAX_ALIGN_T)
_testlimitedcapi.ALIGNOF_MAX_ALIGN_T)
# The offsets/sizes we calculated should be aligned.
self.assertEqual(data_offset % _testcapi.ALIGNOF_MAX_ALIGN_T, 0)
self.assertEqual(data_size % _testcapi.ALIGNOF_MAX_ALIGN_T, 0)
self.assertEqual(data_offset % _testlimitedcapi.ALIGNOF_MAX_ALIGN_T, 0)
self.assertEqual(data_size % _testlimitedcapi.ALIGNOF_MAX_ALIGN_T, 0)
sizes = sorted({0, 1, 2, 3, 4, 7, 8, 123,
object.__basicsize__,
@ -1182,7 +1183,7 @@ class TestHeapTypeRelative(unittest.TestCase):
object.__basicsize__+1})
for extra_size in sizes:
with self.subTest(extra_size=extra_size):
Sub = _testcapi.subclass_var_heaptype(
Sub = _testlimitedcapi.subclass_var_heaptype(
_testcapi.HeapCCollection, -extra_size, 0, 0)
collection = Sub(1, 2, 3)
collection.set_data_to_3s()
@ -1196,7 +1197,7 @@ class TestHeapTypeRelative(unittest.TestCase):
with self.assertRaises(SystemError,
msg="Cannot extend variable-size class without "
+ "Py_TPFLAGS_ITEMS_AT_END"):
_testcapi.subclass_heaptype(int, -8, 0)
_testlimitedcapi.subclass_heaptype(int, -8, 0)
def test_heaptype_relative_members(self):
"""Test HeapCCollection subclasses work properly"""
@ -1209,7 +1210,7 @@ class TestHeapTypeRelative(unittest.TestCase):
for offset in sizes:
with self.subTest(extra_base_size=extra_base_size, extra_size=extra_size, offset=offset):
if offset < extra_size:
Sub = _testcapi.make_heaptype_with_member(
Sub = _testlimitedcapi.make_heaptype_with_member(
extra_base_size, -extra_size, offset, True)
Base = Sub.mro()[1]
instance = Sub()
@ -1228,29 +1229,29 @@ class TestHeapTypeRelative(unittest.TestCase):
instance.set_memb_relative(0)
else:
with self.assertRaises(SystemError):
Sub = _testcapi.make_heaptype_with_member(
Sub = _testlimitedcapi.make_heaptype_with_member(
extra_base_size, -extra_size, offset, True)
with self.assertRaises(SystemError):
Sub = _testcapi.make_heaptype_with_member(
Sub = _testlimitedcapi.make_heaptype_with_member(
extra_base_size, extra_size, offset, True)
with self.subTest(extra_base_size=extra_base_size, extra_size=extra_size):
with self.assertRaises(SystemError):
Sub = _testcapi.make_heaptype_with_member(
Sub = _testlimitedcapi.make_heaptype_with_member(
extra_base_size, -extra_size, -1, True)
def test_heaptype_relative_members_errors(self):
with self.assertRaisesRegex(
SystemError,
r"With Py_RELATIVE_OFFSET, basicsize must be negative"):
_testcapi.make_heaptype_with_member(0, 1234, 0, True)
_testlimitedcapi.make_heaptype_with_member(0, 1234, 0, True)
with self.assertRaisesRegex(
SystemError, r"Member offset out of range \(0\.\.-basicsize\)"):
_testcapi.make_heaptype_with_member(0, -8, 1234, True)
_testlimitedcapi.make_heaptype_with_member(0, -8, 1234, True)
with self.assertRaisesRegex(
SystemError, r"Member offset out of range \(0\.\.-basicsize\)"):
_testcapi.make_heaptype_with_member(0, -8, -1, True)
_testlimitedcapi.make_heaptype_with_member(0, -8, -1, True)
Sub = _testcapi.make_heaptype_with_member(0, -8, 0, True)
Sub = _testlimitedcapi.make_heaptype_with_member(0, -8, 0, True)
instance = Sub()
with self.assertRaisesRegex(
SystemError, r"PyMember_GetOne used with Py_RELATIVE_OFFSET"):
@ -2264,10 +2265,19 @@ class TestThreadState(unittest.TestCase):
_testcapi.test_current_tstate_matches()
def get_test_funcs(mod, exclude_prefix=None):
funcs = {}
for name in dir(mod):
if not name.startswith('test_'):
continue
if exclude_prefix is not None and name.startswith(exclude_prefix):
continue
funcs[name] = getattr(mod, name)
return funcs
class Test_testcapi(unittest.TestCase):
locals().update((name, getattr(_testcapi, name))
for name in dir(_testcapi)
if name.startswith('test_'))
locals().update(get_test_funcs(_testcapi))
# Suppress warning from PyUnicode_FromUnicode().
@warnings_helper.ignore_warnings(category=DeprecationWarning)
@ -2278,11 +2288,13 @@ class Test_testcapi(unittest.TestCase):
self.assertEqual(_testcapi.Py_Version, sys.hexversion)
class Test_testlimitedcapi(unittest.TestCase):
locals().update(get_test_funcs(_testlimitedcapi))
class Test_testinternalcapi(unittest.TestCase):
locals().update((name, getattr(_testinternalcapi, name))
for name in dir(_testinternalcapi)
if name.startswith('test_')
and not name.startswith('test_lock_'))
locals().update(get_test_funcs(_testinternalcapi,
exclude_prefix='test_lock_'))
@threading_helper.requires_working_threading()

View File

@ -162,7 +162,8 @@
@MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
@MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c
@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/vectorcall_limited.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/bytearray.c _testcapi/bytes.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/pyos.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/heaptype_relative.c _testcapi/gc.c _testcapi/sys.c _testcapi/hash.c _testcapi/time.c
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/bytearray.c _testcapi/bytes.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/pyos.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/sys.c _testcapi/hash.c _testcapi/time.c
@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/vectorcall_limited.c _testlimitedcapi/heaptype_relative.c
@MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c
@MODULE__TESTCLINIC_LIMITED_TRUE@_testclinic_limited _testclinic_limited.c

View File

@ -1,20 +0,0 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_testcapi_call_vectorcall__doc__,
"call_vectorcall($module, callable, /)\n"
"--\n"
"\n");
#define _TESTCAPI_CALL_VECTORCALL_METHODDEF \
{"call_vectorcall", (PyCFunction)_testcapi_call_vectorcall, METH_O, _testcapi_call_vectorcall__doc__},
PyDoc_STRVAR(_testcapi_call_vectorcall_method__doc__,
"call_vectorcall_method($module, callable, /)\n"
"--\n"
"\n");
#define _TESTCAPI_CALL_VECTORCALL_METHOD_METHODDEF \
{"call_vectorcall_method", (PyCFunction)_testcapi_call_vectorcall_method, METH_O, _testcapi_call_vectorcall_method__doc__},
/*[clinic end generated code: output=e980906a39602528 input=a9049054013a1b77]*/

View File

@ -61,7 +61,4 @@ int _PyTestCapi_Init_Sys(PyObject *module);
int _PyTestCapi_Init_Hash(PyObject *module);
int _PyTestCapi_Init_Time(PyObject *module);
int _PyTestCapi_Init_VectorcallLimited(PyObject *module);
int _PyTestCapi_Init_HeaptypeRelative(PyObject *module);
#endif // Py_TESTCAPI_PARTS_H

View File

@ -4098,12 +4098,6 @@ PyInit__testcapi(void)
if (_PyTestCapi_Init_PyAtomic(m) < 0) {
return NULL;
}
if (_PyTestCapi_Init_VectorcallLimited(m) < 0) {
return NULL;
}
if (_PyTestCapi_Init_HeaptypeRelative(m) < 0) {
return NULL;
}
if (_PyTestCapi_Init_Hash(m) < 0) {
return NULL;
}

View File

@ -0,0 +1,36 @@
/*
* Test the limited C API.
*
* The 'test_*' functions exported by this module are run as part of the
* standard Python regression test, via Lib/test/test_capi.py.
*/
#include "_testlimitedcapi/parts.h"
static PyMethodDef TestMethods[] = {
{NULL, NULL} /* sentinel */
};
static struct PyModuleDef _testlimitedcapimodule = {
PyModuleDef_HEAD_INIT,
.m_name = "_testlimitedcapi",
.m_size = 0,
.m_methods = TestMethods,
};
PyMODINIT_FUNC
PyInit__testlimitedcapi(void)
{
PyObject *mod = PyModule_Create(&_testlimitedcapimodule);
if (mod == NULL) {
return NULL;
}
if (_PyTestCapi_Init_VectorcallLimited(mod) < 0) {
return NULL;
}
if (_PyTestCapi_Init_HeaptypeRelative(mod) < 0) {
return NULL;
}
return mod;
}

View File

@ -0,0 +1,20 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_testlimitedcapi_call_vectorcall__doc__,
"call_vectorcall($module, callable, /)\n"
"--\n"
"\n");
#define _TESTLIMITEDCAPI_CALL_VECTORCALL_METHODDEF \
{"call_vectorcall", (PyCFunction)_testlimitedcapi_call_vectorcall, METH_O, _testlimitedcapi_call_vectorcall__doc__},
PyDoc_STRVAR(_testlimitedcapi_call_vectorcall_method__doc__,
"call_vectorcall_method($module, callable, /)\n"
"--\n"
"\n");
#define _TESTLIMITEDCAPI_CALL_VECTORCALL_METHOD_METHODDEF \
{"call_vectorcall_method", (PyCFunction)_testlimitedcapi_call_vectorcall_method, METH_O, _testlimitedcapi_call_vectorcall_method__doc__},
/*[clinic end generated code: output=5976b9b360e1ff30 input=a9049054013a1b77]*/

View File

@ -1,9 +1,3 @@
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
#define Py_LIMITED_API 0x030c0000 // 3.12
#endif
#include "parts.h"
#include <stddef.h> // max_align_t
#include <string.h> // memset

View File

@ -0,0 +1,27 @@
#ifndef Py_TESTLIMITEDCAPI_PARTS_H
#define Py_TESTLIMITEDCAPI_PARTS_H
// Always enable assertions
#undef NDEBUG
#include "pyconfig.h" // Py_GIL_DISABLED
// Use the limited C API
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000 // 3.12
#endif
// Make sure that the internal C API cannot be used.
#undef Py_BUILD_CORE_MODULE
#undef Py_BUILD_CORE_BUILTIN
#include "Python.h"
#ifdef Py_BUILD_CORE
# error "Py_BUILD_CORE macro must not be defined"
#endif
int _PyTestCapi_Init_VectorcallLimited(PyObject *module);
int _PyTestCapi_Init_HeaptypeRelative(PyObject *module);
#endif // Py_TESTLIMITEDCAPI_PARTS_H

View File

@ -1,18 +1,12 @@
/* Test Vectorcall in the limited API */
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
#define Py_LIMITED_API 0x030c0000 // 3.12
#endif
#include "parts.h"
#include "clinic/vectorcall_limited.c.h"
/*[clinic input]
module _testcapi
module _testlimitedcapi
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2700057f9c1135ba]*/
static PyObject *
LimitedVectorCallClass_tpcall(PyObject *self, PyObject *args, PyObject *kwargs) {
@ -40,15 +34,15 @@ LimitedVectorCallClass_new(PyTypeObject *tp, PyTypeObject *a, PyTypeObject *kw)
}
/*[clinic input]
_testcapi.call_vectorcall
_testlimitedcapi.call_vectorcall
callable: object
/
[clinic start generated code]*/
static PyObject *
_testcapi_call_vectorcall(PyObject *module, PyObject *callable)
/*[clinic end generated code: output=bae81eec97fcaad7 input=55d88f92240957ee]*/
_testlimitedcapi_call_vectorcall(PyObject *module, PyObject *callable)
/*[clinic end generated code: output=9cbb7832263a8eef input=0743636c12dccb28]*/
{
PyObject *args[3] = { NULL, NULL, NULL };
PyObject *kwname = NULL, *kwnames = NULL, *result = NULL;
@ -93,15 +87,15 @@ leave:
}
/*[clinic input]
_testcapi.call_vectorcall_method
_testlimitedcapi.call_vectorcall_method
callable: object
/
[clinic start generated code]*/
static PyObject *
_testcapi_call_vectorcall_method(PyObject *module, PyObject *callable)
/*[clinic end generated code: output=e661f48dda08b6fb input=5ba81c27511395b6]*/
_testlimitedcapi_call_vectorcall_method(PyObject *module, PyObject *callable)
/*[clinic end generated code: output=4558323a46cc09eb input=a736f7dbf15f1be5]*/
{
PyObject *args[3] = { NULL, NULL, NULL };
PyObject *name = NULL, *kwname = NULL,
@ -167,7 +161,7 @@ static PyType_Slot LimitedVectorallClass_slots[] = {
};
static PyType_Spec LimitedVectorCallClass_spec = {
.name = "_testcapi.LimitedVectorCallClass",
.name = "_testlimitedcapi.LimitedVectorCallClass",
.basicsize = (int)(sizeof(PyObject) + sizeof(vectorcallfunc)),
.flags = Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_HAVE_VECTORCALL
@ -176,8 +170,8 @@ static PyType_Spec LimitedVectorCallClass_spec = {
};
static PyMethodDef TestMethods[] = {
_TESTCAPI_CALL_VECTORCALL_METHODDEF
_TESTCAPI_CALL_VECTORCALL_METHOD_METHODDEF
_TESTLIMITEDCAPI_CALL_VECTORCALL_METHODDEF
_TESTLIMITEDCAPI_CALL_VECTORCALL_METHOD_METHODDEF
{NULL},
};

View File

@ -96,9 +96,7 @@
<ClCompile Include="..\Modules\_testcapimodule.c" />
<ClCompile Include="..\Modules\_testcapi\getargs.c" />
<ClCompile Include="..\Modules\_testcapi\vectorcall.c" />
<ClCompile Include="..\Modules\_testcapi\vectorcall_limited.c" />
<ClCompile Include="..\Modules\_testcapi\heaptype.c" />
<ClCompile Include="..\Modules\_testcapi\heaptype_relative.c" />
<ClCompile Include="..\Modules\_testcapi\abstract.c" />
<ClCompile Include="..\Modules\_testcapi\bytearray.c" />
<ClCompile Include="..\Modules\_testcapi\bytes.c" />

View File

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|ARM">
<Configuration>PGInstrument</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|ARM64">
<Configuration>PGInstrument</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|Win32">
<Configuration>PGInstrument</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|x64">
<Configuration>PGInstrument</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|ARM">
<Configuration>PGUpdate</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|ARM64">
<Configuration>PGUpdate</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|Win32">
<Configuration>PGUpdate</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|x64">
<Configuration>PGUpdate</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}</ProjectGuid>
<RootNamespace>_testlimitedcapi</RootNamespace>
<Keyword>Win32Proj</Keyword>
<SupportPGO>false</SupportPGO>
</PropertyGroup>
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup>
<TargetExt>$(PyStdlibPydExt)</TargetExt>
</PropertyGroup>
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="pyproject.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
</PropertyGroup>
<ItemGroup>
<ClCompile Include="..\Modules\_testlimitedcapi.c" />
<ClCompile Include="..\Modules\_testlimitedcapi\vectorcall_limited.c" />
<ClCompile Include="..\Modules\_testlimitedcapi\heaptype_relative.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="pythoncore.vcxproj">
<Project>{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="python3dll.vcxproj">
<Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{a76a90d8-8e8b-4c36-8f58-8bd46abe9f5e}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{071b2ff4-e5a1-4e79-b0c5-cf46b0094a80}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Modules\_testlimitedcapi\vectorcall_limited.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Modules\_testlimitedcapi\heaptype_relative.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Modules\_testlimitedcapi.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -77,7 +77,7 @@
<ExtensionModules Include="@(ExternalModules->'%(Identity)')" Condition="$(IncludeExternals)" />
<Projects Include="@(ExtensionModules->'%(Identity).vcxproj')" Condition="$(IncludeExtensions)" />
<!-- Test modules -->
<TestModules Include="_ctypes_test;_testbuffer;_testcapi;_testinternalcapi;_testembed;_testimportmultiple;_testmultiphase;_testsinglephase;_testconsole;_testclinic;_testclinic_limited" />
<TestModules Include="_ctypes_test;_testbuffer;_testcapi;_testlimitedcapi;_testinternalcapi;_testembed;_testimportmultiple;_testmultiphase;_testsinglephase;_testconsole;_testclinic;_testclinic_limited" />
<TestModules Include="xxlimited" Condition="'$(Configuration)' == 'Release'" />
<TestModules Include="xxlimited_35" Condition="'$(Configuration)' == 'Release'" />
<Projects Include="@(TestModules->'%(Identity).vcxproj')" Condition="$(IncludeTests)">

View File

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30028.174
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}"
ProjectSection(SolutionItems) = preProject
@ -159,6 +159,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_wmi", "_wmi.vcxproj", "{54
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testclinic_limited", "_testclinic_limited.vcxproj", "{01FDF29A-40A1-46DF-84F5-85EBBD2A2410}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testlimitedcapi", "_testlimitedcapi.vcxproj", "{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@ -1648,6 +1650,38 @@ Global
{01FDF29A-40A1-46DF-84F5-85EBBD2A2410}.Release|Win32.Build.0 = Release|Win32
{01FDF29A-40A1-46DF-84F5-85EBBD2A2410}.Release|x64.ActiveCfg = Release|x64
{01FDF29A-40A1-46DF-84F5-85EBBD2A2410}.Release|x64.Build.0 = Release|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|ARM.ActiveCfg = Debug|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|ARM.Build.0 = Debug|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|ARM64.ActiveCfg = Debug|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|ARM64.Build.0 = Debug|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|Win32.ActiveCfg = Debug|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|Win32.Build.0 = Debug|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|x64.ActiveCfg = Debug|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Debug|x64.Build.0 = Debug|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|ARM.Build.0 = PGInstrument|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|Win32.Build.0 = PGInstrument|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|x64.ActiveCfg = PGInstrument|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGInstrument|x64.Build.0 = PGInstrument|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|ARM.Build.0 = PGUpdate|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|Win32.Build.0 = PGUpdate|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|x64.ActiveCfg = PGUpdate|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.PGUpdate|x64.Build.0 = PGUpdate|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|ARM.ActiveCfg = Release|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|ARM.Build.0 = Release|ARM
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|ARM64.ActiveCfg = Release|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|ARM64.Build.0 = Release|ARM64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|Win32.ActiveCfg = Release|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|Win32.Build.0 = Release|Win32
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|x64.ActiveCfg = Release|x64
{7467D86C-1CEB-4CB9-B65E-E9A54ABDC933}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -131,29 +131,31 @@ xxlimited_35
The following sub-projects are for individual modules of the standard
library which are implemented in C; each one builds a DLL (renamed to
.pyd) of the same name as the project:
_asyncio
_ctypes
_ctypes_test
_zoneinfo
_decimal
_elementtree
_hashlib
_multiprocessing
_overlapped
_socket
_testbuffer
_testcapi
_testclinic
_testclinic_limited
_testconsole
_testimportmultiple
_testmultiphase
_testsinglephase
_tkinter
pyexpat
select
unicodedata
winsound
* _asyncio
* _ctypes
* _ctypes_test
* _zoneinfo
* _decimal
* _elementtree
* _hashlib
* _multiprocessing
* _overlapped
* _socket
* _testbuffer
* _testcapi
* _testlimitedcapi
* _testinternalcapi
* _testclinic
* _testclinic_limited
* _testconsole
* _testimportmultiple
* _testmultiphase
* _testsinglephase
* _tkinter
* pyexpat
* select
* unicodedata
* winsound
The following Python-controlled sub-projects wrap external projects.
Note that these external libraries are not necessary for a working
@ -309,6 +311,8 @@ _testclinic_limited extension, the file Modules/_testclinic_limited.c:
* In PCbuild/, copy _testclinic.vcxproj to _testclinic_limited.vcxproj,
replace RootNamespace value with `_testclinic_limited`, replace
`_asyncio.c` with `_testclinic_limited.c`.
* In PCbuild/, copy _testclinic.vcxproj.filters to
_testclinic_limited.vcxproj.filters, edit the list of files in the new file.
* Open Visual Studio, open PCbuild\pcbuild.sln solution, add the
PCbuild\_testclinic_limited.vcxproj project to the solution ("add existing
project).

View File

@ -32,6 +32,7 @@ IGNORE = {
'_testconsole',
'_testimportmultiple',
'_testinternalcapi',
'_testlimitedcapi',
'_testmultiphase',
'_testsinglephase',
'_testexternalinspection',

View File

@ -15,8 +15,8 @@ FILES_WITHOUT_INTERNAL_CAPI = frozenset((
# C files in the fhe following directories must not be built with
# Py_BUILD_CORE.
DIRS_WITHOUT_INTERNAL_CAPI = frozenset((
# Modules/_testcapi/
'_testcapi',
'_testcapi', # Modules/_testcapi/
'_testlimitedcapi', # Modules/_testlimitedcapi/
))
TOOL = 'gcc'

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define exts=_testcapi;_ctypes_test;_testbuffer;_testimportmultiple;_testmultiphase;_testsinglephase;_testconsole;_testinternalcapi;_testclinic;_testclinic_limited ?>
<?define exts=_testcapi;_testlimitedcapi;_ctypes_test;_testbuffer;_testimportmultiple;_testmultiphase;_testsinglephase;_testconsole;_testinternalcapi;_testclinic;_testclinic_limited ?>
<Fragment>
<ComponentGroup Id="test_extensions">
<?foreach ext in $(var.exts)?>

45
configure generated vendored
View File

@ -671,6 +671,8 @@ MODULE__TESTBUFFER_FALSE
MODULE__TESTBUFFER_TRUE
MODULE__TESTINTERNALCAPI_FALSE
MODULE__TESTINTERNALCAPI_TRUE
MODULE__TESTLIMITEDCAPI_FALSE
MODULE__TESTLIMITEDCAPI_TRUE
MODULE__TESTCLINIC_LIMITED_FALSE
MODULE__TESTCLINIC_LIMITED_TRUE
MODULE__TESTCLINIC_FALSE
@ -27301,6 +27303,7 @@ SRCDIRS="\
Modules/_sre \
Modules/_testcapi \
Modules/_testinternalcapi \
Modules/_testlimitedcapi \
Modules/_xxtestfuzz \
Modules/cjkcodecs \
Modules/expat \
@ -30771,6 +30774,44 @@ fi
printf "%s\n" "$py_cv_module__testclinic_limited" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _testlimitedcapi" >&5
printf %s "checking for stdlib extension module _testlimitedcapi... " >&6; }
if test "$py_cv_module__testlimitedcapi" != "n/a"
then :
if test "$TEST_MODULES" = yes
then :
if true
then :
py_cv_module__testlimitedcapi=yes
else $as_nop
py_cv_module__testlimitedcapi=missing
fi
else $as_nop
py_cv_module__testlimitedcapi=disabled
fi
fi
as_fn_append MODULE_BLOCK "MODULE__TESTLIMITEDCAPI_STATE=$py_cv_module__testlimitedcapi$as_nl"
if test "x$py_cv_module__testlimitedcapi" = xyes
then :
fi
if test "$py_cv_module__testlimitedcapi" = yes; then
MODULE__TESTLIMITEDCAPI_TRUE=
MODULE__TESTLIMITEDCAPI_FALSE='#'
else
MODULE__TESTLIMITEDCAPI_TRUE='#'
MODULE__TESTLIMITEDCAPI_FALSE=
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__testlimitedcapi" >&5
printf "%s\n" "$py_cv_module__testlimitedcapi" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _testinternalcapi" >&5
printf %s "checking for stdlib extension module _testinternalcapi... " >&6; }
if test "$py_cv_module__testinternalcapi" != "n/a"
@ -31557,6 +31598,10 @@ if test -z "${MODULE__TESTCLINIC_LIMITED_TRUE}" && test -z "${MODULE__TESTCLINIC
as_fn_error $? "conditional \"MODULE__TESTCLINIC_LIMITED\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${MODULE__TESTLIMITEDCAPI_TRUE}" && test -z "${MODULE__TESTLIMITEDCAPI_FALSE}"; then
as_fn_error $? "conditional \"MODULE__TESTLIMITEDCAPI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${MODULE__TESTINTERNALCAPI_TRUE}" && test -z "${MODULE__TESTINTERNALCAPI_FALSE}"; then
as_fn_error $? "conditional \"MODULE__TESTINTERNALCAPI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -6813,6 +6813,7 @@ SRCDIRS="\
Modules/_sre \
Modules/_testcapi \
Modules/_testinternalcapi \
Modules/_testlimitedcapi \
Modules/_xxtestfuzz \
Modules/cjkcodecs \
Modules/expat \
@ -7622,6 +7623,7 @@ PY_STDLIB_MOD([_testcapi],
[], [], [$LIBATOMIC])
PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testclinic_limited], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testlimitedcapi], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])