gh-109599: Expose `CapsuleType` via the `_types` module by AA-Turner · Pull Request #131969 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions Lib/types.py
1 change: 1 addition & 0 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ PYTHONPATH=$(COREPYTHONPATH)
#_socket socketmodule.c
#_statistics _statisticsmodule.c
#_struct _struct.c
#_types _typesmodule.c
#_typing _typingmodule.c
#_zoneinfo _zoneinfo.c
#array arraymodule.c
Expand Down
1 change: 1 addition & 0 deletions Modules/Setup.bootstrap.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ _sre _sre/sre.c
_sysconfig _sysconfig.c
_thread _threadmodule.c
time timemodule.c
_types _typesmodule.c
_typing _typingmodule.c
_weakref _weakref.c

Expand Down
37 changes: 37 additions & 0 deletions Modules/_typesmodule.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* _types module */

#include "Python.h"
#include "pycore_namespace.h" // _PyNamespace_Type

static int
_types_exec(PyObject *m)
{
if (PyModule_AddObjectRef(m, "CapsuleType", (PyObject *)&PyCapsule_Type) < 0) {
Comment thread
AA-Turner marked this conversation as resolved.
return -1;
}
if (PyModule_AddObjectRef(m, "SimpleNamespace", (PyObject *)&_PyNamespace_Type) < 0) {
return -1;
}
return 0;
}

static struct PyModuleDef_Slot _typesmodule_slots[] = {
{Py_mod_exec, _types_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

static struct PyModuleDef typesmodule = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "_types",
.m_doc = "Define names for built-in types.",
.m_size = 0,
.m_slots = _typesmodule_slots,
};

PyMODINIT_FUNC
PyInit__types(void)
{
return PyModuleDef_Init(&typesmodule);
}
2 changes: 2 additions & 0 deletions PC/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern PyObject* PyInit__sha2(void);
extern PyObject* PyInit__sha3(void);
extern PyObject* PyInit__statistics(void);
extern PyObject* PyInit__sysconfig(void);
extern PyObject* PyInit__types(void);
extern PyObject* PyInit__typing(void);
extern PyObject* PyInit__blake2(void);
extern PyObject* PyInit_time(void);
Expand Down Expand Up @@ -107,6 +108,7 @@ struct _inittab _PyImport_Inittab[] = {
{"time", PyInit_time},
{"_thread", PyInit__thread},
{"_tokenize", PyInit__tokenize},
{"_types", PyInit__types},
{"_typing", PyInit__typing},
{"_statistics", PyInit__statistics},
#ifdef WIN32
Expand Down
1 change: 1 addition & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
<ClCompile Include="..\Modules\_sysconfig.c" />
<ClCompile Include="..\Modules\_threadmodule.c" />
<ClCompile Include="..\Modules\_tracemalloc.c" />
<ClCompile Include="..\Modules\_typesmodule.c" />
<ClCompile Include="..\Modules\_typingmodule.c" />
<ClCompile Include="..\Modules\timemodule.c" />
<ClCompile Include="..\Modules\xxsubtype.c" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,9 @@
<ClCompile Include="..\Modules\_statisticsmodule.c">
<Filter>Modules</Filter>
</ClCompile>
<ClCompile Include="..\Modules\_typesmodule.c">
<Filter>Modules</Filter>
</ClCompile>
<ClCompile Include="..\Modules\_typingmodule.c">
<Filter>Modules</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions Python/stdlib_module_names.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions configure.ac