Browse Source
bpo-36635: Add _testinternalcapi module (GH-12841)
bpo-36635: Add _testinternalcapi module (GH-12841)
Add a new _testinternalcapi module to test the internal C API. Move _Py_GetConfigsAsDict() function to the internal C API: _testembed now uses _testinternalcapi to access the function.pull/12876/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 172 additions and 49 deletions
-
5Include/cpython/coreconfig.h
-
5Include/internal/pycore_coreconfig.h
-
2Lib/test/pythoninfo.py
-
1Misc/NEWS.d/next/Tests/2019-04-15-16-55-49.bpo-36635.__FTq9.rst
-
1Modules/Setup
-
8Modules/_testcapimodule.c
-
45Modules/_testinternalcapi.c
-
94PCbuild/_testinternalcapi.vcxproj
-
13PCbuild/_testinternalcapi.vcxproj.filters
-
4PCbuild/pcbuild.proj
-
2PCbuild/pcbuild.sln
-
37Programs/_testembed.c
-
4setup.py
@ -0,0 +1 @@ |
|||
Add a new :mod:`_testinternalcapi` module to test the internal C API. |
|||
@ -0,0 +1,45 @@ |
|||
/* |
|||
* C Extension module to test Python internal C APIs (Include/internal). |
|||
*/ |
|||
|
|||
#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE) |
|||
# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined" |
|||
#endif |
|||
|
|||
#define PY_SSIZE_T_CLEAN |
|||
|
|||
#include "Python.h" |
|||
#include "pycore_coreconfig.h" |
|||
|
|||
|
|||
static PyObject * |
|||
get_configs(PyObject *self, PyObject *Py_UNUSED(args)) |
|||
{ |
|||
return _Py_GetConfigsAsDict(); |
|||
} |
|||
|
|||
|
|||
static PyMethodDef TestMethods[] = { |
|||
{"get_configs", get_configs, METH_NOARGS}, |
|||
{NULL, NULL} /* sentinel */ |
|||
}; |
|||
|
|||
|
|||
static struct PyModuleDef _testcapimodule = { |
|||
PyModuleDef_HEAD_INIT, |
|||
"_testinternalcapi", |
|||
NULL, |
|||
-1, |
|||
TestMethods, |
|||
NULL, |
|||
NULL, |
|||
NULL, |
|||
NULL |
|||
}; |
|||
|
|||
|
|||
PyMODINIT_FUNC |
|||
PyInit__testinternalcapi(void) |
|||
{ |
|||
return PyModule_Create(&_testcapimodule); |
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
<?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|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|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|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|Win32"> |
|||
<Configuration>Release</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
<ProjectConfiguration Include="Release|x64"> |
|||
<Configuration>Release</Configuration> |
|||
<Platform>x64</Platform> |
|||
</ProjectConfiguration> |
|||
</ItemGroup> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>{900342D7-516A-4469-B1AD-59A66E49A25F}</ProjectGuid> |
|||
<RootNamespace>_testinternalcapi</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>.pyd</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\_testinternalcapi.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> |
|||
</ItemGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
|||
<ImportGroup Label="ExtensionTargets"> |
|||
</ImportGroup> |
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
<?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>{136fc5eb-7fe4-4486-8c6d-b49f37a00199}</UniqueIdentifier> |
|||
</Filter> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="..\Modules\_testinternalcapi.c"> |
|||
<Filter>Source Files</Filter> |
|||
</ClCompile> |
|||
</ItemGroup> |
|||
</Project> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue