summaryrefslogtreecommitdiffstats
path: root/Objects/genericaliasobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-07-17 19:44:10 (GMT)
committerGitHub <noreply@github.com>2021-07-17 19:44:10 (GMT)
commit0fd27375cabd12e68a2f12cfeca11a2d5043429e (patch)
treeacb748d0bc66167f6f0d6d30123a205fc5af3e9b /Objects/genericaliasobject.c
parentf88e138a1aa3b9a9e013963e4fd7d5cce6a0b85c (diff)
downloadcpython-0fd27375cabd12e68a2f12cfeca11a2d5043429e.zip
cpython-0fd27375cabd12e68a2f12cfeca11a2d5043429e.tar.gz
cpython-0fd27375cabd12e68a2f12cfeca11a2d5043429e.tar.bz2
bpo-44654: Refactor and clean up the union type implementation (GH-27196)
Diffstat (limited to 'Objects/genericaliasobject.c')
-rw-r--r--Objects/genericaliasobject.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index d3d3871..dda53cb 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -2,7 +2,7 @@
#include "Python.h"
#include "pycore_object.h"
-#include "pycore_unionobject.h" // _Py_union_as_number
+#include "pycore_unionobject.h" // _Py_union_type_or, _PyGenericAlias_Check
#include "structmember.h" // PyMemberDef
typedef struct {
@@ -441,8 +441,7 @@ ga_getattro(PyObject *self, PyObject *name)
static PyObject *
ga_richcompare(PyObject *a, PyObject *b, int op)
{
- if (!PyObject_TypeCheck(a, &Py_GenericAliasType) ||
- !PyObject_TypeCheck(b, &Py_GenericAliasType) ||
+ if (!_PyGenericAlias_Check(b) ||
(op != Py_EQ && op != Py_NE))
{
Py_RETURN_NOTIMPLEMENTED;
@@ -622,7 +621,7 @@ ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
static PyNumberMethods ga_as_number = {
- .nb_or = (binaryfunc)_Py_union_type_or, // Add __or__ function
+ .nb_or = _Py_union_type_or, // Add __or__ function
};
// TODO: