mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-105499: Merge typing.Union and types.UnionType (#105511)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Ken Jin <kenjin@python.org> Co-authored-by: Carl Meyer <carl@oddbird.net>
This commit is contained in:
parent
e091520fdb
commit
dc6d66f44c
20 changed files with 562 additions and 327 deletions
|
@ -2,8 +2,8 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK, PyAnnotateFormat
|
||||
#include "pycore_typevarobject.h"
|
||||
#include "pycore_unionobject.h" // _Py_union_type_or
|
||||
|
||||
#include "pycore_unionobject.h" // _Py_union_type_or, _Py_union_from_tuple
|
||||
#include "structmember.h"
|
||||
|
||||
/*[clinic input]
|
||||
class typevar "typevarobject *" "&_PyTypeVar_Type"
|
||||
|
@ -370,9 +370,13 @@ type_check(PyObject *arg, const char *msg)
|
|||
static PyObject *
|
||||
make_union(PyObject *self, PyObject *other)
|
||||
{
|
||||
PyObject *args[2] = {self, other};
|
||||
PyObject *result = call_typing_func_object("_make_union", args, 2);
|
||||
return result;
|
||||
PyObject *args = PyTuple_Pack(2, self, other);
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
PyObject *u = _Py_union_from_tuple(args);
|
||||
Py_DECREF(args);
|
||||
return u;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue