mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-43277: Add PySet_CheckExact to the C-API (GH-24598)
For some mysterious reason we have PySet_Check, PyFrozenSet_Check, PyAnySet_Check, PyAnySet_CheckExact and PyFrozenSet_CheckExact but no PySet_CheckExact.
This commit is contained in:
parent
46496f9d12
commit
d439fb304c
6 changed files with 20 additions and 5 deletions
|
@ -4482,7 +4482,7 @@ _PyDictView_Intersect(PyObject* self, PyObject *other)
|
|||
|
||||
/* if other is a set and self is smaller than other,
|
||||
reuse set intersection logic */
|
||||
if (Py_IS_TYPE(other, &PySet_Type) && len_self <= PyObject_Size(other)) {
|
||||
if (PySet_CheckExact(other) && len_self <= PyObject_Size(other)) {
|
||||
_Py_IDENTIFIER(intersection);
|
||||
return _PyObject_CallMethodIdObjArgs(other, &PyId_intersection, self, NULL);
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ set_repr(PySetObject *so)
|
|||
goto done;
|
||||
listrepr = tmp;
|
||||
|
||||
if (!Py_IS_TYPE(so, &PySet_Type))
|
||||
if (!PySet_CheckExact(so))
|
||||
result = PyUnicode_FromFormat("%s({%U})",
|
||||
Py_TYPE(so)->tp_name,
|
||||
listrepr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue