mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and typing (GH-23060)
This commit is contained in:
parent
43c4fb6c90
commit
463c7d3d14
9 changed files with 212 additions and 63 deletions
|
@ -237,8 +237,8 @@ dedup_and_flatten_args(PyObject* args)
|
|||
PyObject* i_element = PyTuple_GET_ITEM(args, i);
|
||||
for (Py_ssize_t j = i + 1; j < arg_length; j++) {
|
||||
PyObject* j_element = PyTuple_GET_ITEM(args, j);
|
||||
int is_ga = Py_TYPE(i_element) == &Py_GenericAliasType &&
|
||||
Py_TYPE(j_element) == &Py_GenericAliasType;
|
||||
int is_ga = PyObject_TypeCheck(i_element, &Py_GenericAliasType) &&
|
||||
PyObject_TypeCheck(j_element, &Py_GenericAliasType);
|
||||
// RichCompare to also deduplicate GenericAlias types (slower)
|
||||
is_duplicate = is_ga ? PyObject_RichCompareBool(i_element, j_element, Py_EQ)
|
||||
: i_element == j_element;
|
||||
|
@ -296,7 +296,7 @@ is_unionable(PyObject *obj)
|
|||
is_new_type(obj) ||
|
||||
is_special_form(obj) ||
|
||||
PyType_Check(obj) ||
|
||||
type == &Py_GenericAliasType ||
|
||||
PyObject_TypeCheck(obj, &Py_GenericAliasType) ||
|
||||
type == &_Py_UnionType);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue