summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-07-24 18:26:02 (GMT)
committerGitHub <noreply@github.com>2021-07-24 18:26:02 (GMT)
commit435a0334d341e5f8faed594d9f015746bb7845db (patch)
tree5c090299361ae9dabe002f2936044a01b1022b16 /Objects
parent4f5980a4f57dab68b9137304f58bd08891d43d5a (diff)
downloadcpython-435a0334d341e5f8faed594d9f015746bb7845db.zip
cpython-435a0334d341e5f8faed594d9f015746bb7845db.tar.gz
cpython-435a0334d341e5f8faed594d9f015746bb7845db.tar.bz2
bpo-44676: Serialize the union type using only public API (GH-27323)
Remove also the _from_args() constructor.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unionobject.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/Objects/unionobject.c b/Objects/unionobject.c
index 9804d87..475311e 100644
--- a/Objects/unionobject.c
+++ b/Objects/unionobject.c
@@ -235,21 +235,6 @@ is_unionable(PyObject *obj)
_PyUnion_Check(obj));
}
-static int
-is_args_unionable(PyObject *args)
-{
- Py_ssize_t nargs = PyTuple_GET_SIZE(args);
- for (Py_ssize_t iarg = 0; iarg < nargs; iarg++) {
- PyObject *arg = PyTuple_GET_ITEM(args, iarg);
- if (!is_unionable(arg)) {
- PyErr_Format(PyExc_TypeError,
- "Each union argument must be a type, got %.100R", arg);
- return 0;
- }
- }
- return 1;
-}
-
PyObject *
_Py_union_type_or(PyObject* self, PyObject* other)
{
@@ -362,47 +347,14 @@ error:
return NULL;
}
-static PyObject *
-union_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
-{
- unionobject *alias = (unionobject *)self;
- PyObject* from_args = PyObject_GetAttrString(self, "_from_args");
- if (from_args == NULL) {
- return NULL;
- }
-
- return Py_BuildValue("N(O)", from_args, alias->args);
-}
-
static PyMemberDef union_members[] = {
{"__args__", T_OBJECT, offsetof(unionobject, args), READONLY},
{0}
};
-static PyObject *
-union_from_args(PyObject *cls, PyObject *args)
-{
- if (!PyTuple_CheckExact(args)) {
- _PyArg_BadArgument("Union._from_args", "argument 'args'", "tuple", args);
- return NULL;
- }
- if (!PyTuple_GET_SIZE(args)) {
- PyErr_SetString(PyExc_ValueError, "args must be not empty");
- return NULL;
- }
-
- if (!is_args_unionable(args)) {
- return NULL;
- }
-
- return make_union(args);
-}
-
static PyMethodDef union_methods[] = {
- {"_from_args", union_from_args, METH_O | METH_CLASS},
{"__instancecheck__", union_instancecheck, METH_O},
{"__subclasscheck__", union_subclasscheck, METH_O},
- {"__reduce__", union_reduce, METH_NOARGS},
{0}};