aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/_typingmodule.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <dcherednik@ydb.tech>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Modules/_typingmodule.c
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
downloadydb-31f2a419764a8ba77c2a970cfc80056c6cd06756.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Modules/_typingmodule.c')
-rw-r--r--contrib/tools/python3/src/Modules/_typingmodule.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/contrib/tools/python3/src/Modules/_typingmodule.c b/contrib/tools/python3/src/Modules/_typingmodule.c
index 8b6faa646d..39a124a26a 100644
--- a/contrib/tools/python3/src/Modules/_typingmodule.c
+++ b/contrib/tools/python3/src/Modules/_typingmodule.c
@@ -1,6 +1,12 @@
/* typing accelerator C extension: _typing module. */
+#ifndef Py_BUILD_CORE
+#define Py_BUILD_CORE
+#endif
+
#include "Python.h"
+#include "internal/pycore_interp.h"
+#include "internal/pycore_typevarobject.h"
#include "clinic/_typingmodule.c.h"
/*[clinic input]
@@ -23,8 +29,7 @@ static PyObject *
_typing__idfunc(PyObject *module, PyObject *x)
/*[clinic end generated code: output=63c38be4a6ec5f2c input=49f17284b43de451]*/
{
- Py_INCREF(x);
- return x;
+ return Py_NewRef(x);
}
@@ -36,7 +41,33 @@ static PyMethodDef typing_methods[] = {
PyDoc_STRVAR(typing_doc,
"Accelerators for the typing module.\n");
+static int
+_typing_exec(PyObject *m)
+{
+ PyInterpreterState *interp = PyInterpreterState_Get();
+
+#define EXPORT_TYPE(name, typename) \
+ if (PyModule_AddObjectRef(m, name, \
+ (PyObject *)interp->cached_objects.typename) < 0) { \
+ return -1; \
+ }
+
+ EXPORT_TYPE("TypeVar", typevar_type);
+ EXPORT_TYPE("TypeVarTuple", typevartuple_type);
+ EXPORT_TYPE("ParamSpec", paramspec_type);
+ EXPORT_TYPE("ParamSpecArgs", paramspecargs_type);
+ EXPORT_TYPE("ParamSpecKwargs", paramspeckwargs_type);
+ EXPORT_TYPE("Generic", generic_type);
+#undef EXPORT_TYPE
+ if (PyModule_AddObjectRef(m, "TypeAliasType", (PyObject *)&_PyTypeAlias_Type) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
static struct PyModuleDef_Slot _typingmodule_slots[] = {
+ {Py_mod_exec, _typing_exec},
+ {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};