bpo-32999: Revert GH-6002 (fc7df0e6
) (GH-6189)
bpo-33018 (GH-5944) fixed bpo-32999 too. So fc7df0e6
is not required
anymore. Revert it except test case.
This commit is contained in:
parent
40472dd42d
commit
f757b72b25
|
@ -16,7 +16,6 @@ _Py_IDENTIFIER(__abstractmethods__);
|
||||||
_Py_IDENTIFIER(__class__);
|
_Py_IDENTIFIER(__class__);
|
||||||
_Py_IDENTIFIER(__dict__);
|
_Py_IDENTIFIER(__dict__);
|
||||||
_Py_IDENTIFIER(__bases__);
|
_Py_IDENTIFIER(__bases__);
|
||||||
_Py_IDENTIFIER(__mro__);
|
|
||||||
_Py_IDENTIFIER(_abc_impl);
|
_Py_IDENTIFIER(_abc_impl);
|
||||||
_Py_IDENTIFIER(__subclasscheck__);
|
_Py_IDENTIFIER(__subclasscheck__);
|
||||||
_Py_IDENTIFIER(__subclasshook__);
|
_Py_IDENTIFIER(__subclasshook__);
|
||||||
|
@ -574,7 +573,7 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ok, *mro = NULL, *subclasses = NULL, *result = NULL;
|
PyObject *ok, *subclasses = NULL, *result = NULL;
|
||||||
Py_ssize_t pos;
|
Py_ssize_t pos;
|
||||||
int incache;
|
int incache;
|
||||||
_abc_data *impl = _get_impl(self);
|
_abc_data *impl = _get_impl(self);
|
||||||
|
@ -643,24 +642,14 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
|
||||||
}
|
}
|
||||||
Py_DECREF(ok);
|
Py_DECREF(ok);
|
||||||
|
|
||||||
/* 4. Check if it's a direct subclass.
|
/* 4. Check if it's a direct subclass. */
|
||||||
*
|
PyObject *mro = ((PyTypeObject *)subclass)->tp_mro;
|
||||||
* if cls in getattr(subclass, '__mro__', ()):
|
assert(PyTuple_Check(mro));
|
||||||
* cls._abc_cache.add(subclass)
|
|
||||||
* return True
|
|
||||||
*/
|
|
||||||
if (_PyObject_LookupAttrId(subclass, &PyId___mro__, &mro) < 0) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (mro != NULL) {
|
|
||||||
if (!PyTuple_Check(mro)) {
|
|
||||||
// Python version supports non-tuple iterable. Keep it as
|
|
||||||
// implementation detail.
|
|
||||||
PyErr_SetString(PyExc_TypeError, "__mro__ is not a tuple");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
for (pos = 0; pos < PyTuple_GET_SIZE(mro); pos++) {
|
for (pos = 0; pos < PyTuple_GET_SIZE(mro); pos++) {
|
||||||
PyObject *mro_item = PyTuple_GET_ITEM(mro, pos);
|
PyObject *mro_item = PyTuple_GET_ITEM(mro, pos);
|
||||||
|
if (mro_item == NULL) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if ((PyObject *)self == mro_item) {
|
if ((PyObject *)self == mro_item) {
|
||||||
if (_add_to_weak_set(&impl->_abc_cache, subclass) < 0) {
|
if (_add_to_weak_set(&impl->_abc_cache, subclass) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -669,7 +658,6 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* 5. Check if it's a subclass of a registered class (recursive). */
|
/* 5. Check if it's a subclass of a registered class (recursive). */
|
||||||
if (subclasscheck_check_registry(impl, subclass, &result)) {
|
if (subclasscheck_check_registry(impl, subclass, &result)) {
|
||||||
|
@ -708,7 +696,6 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
|
||||||
|
|
||||||
end:
|
end:
|
||||||
Py_DECREF(impl);
|
Py_DECREF(impl);
|
||||||
Py_XDECREF(mro);
|
|
||||||
Py_XDECREF(subclasses);
|
Py_XDECREF(subclasses);
|
||||||
Py_XINCREF(result);
|
Py_XINCREF(result);
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue