bpo-44654: Refactor and clean up the union type implementation (GH-27196)

This commit is contained in:
Serhiy Storchaka 2021-07-17 22:44:10 +03:00 committed by GitHub
parent f88e138a1a
commit 0fd27375ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 88 additions and 125 deletions

View file

@ -6,7 +6,7 @@
#include "pycore_object.h" // _Py_CheckSlotResult()
#include "pycore_pyerrors.h" // _PyErr_Occurred()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_unionobject.h" // _Py_UnionType && _Py_Union()
#include "pycore_unionobject.h" // _PyUnion_Check()
#include <ctype.h>
#include <stddef.h> // offsetof()
#include "longintrepr.h"
@ -2623,9 +2623,7 @@ recursive_issubclass(PyObject *derived, PyObject *cls)
"issubclass() arg 1 must be a class"))
return -1;
PyTypeObject *type = Py_TYPE(cls);
int is_union = (PyType_Check(type) && type == &_Py_UnionType);
if (!is_union && !check_class(cls,
if (!_PyUnion_Check(cls) && !check_class(cls,
"issubclass() arg 2 must be a class,"
" a tuple of classes, or a union.")) {
return -1;