-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Py_TYPE(lhs)->tp_as_mapping->mp_subscript is not the same as Dict_Type.tp_as_mapping->mp_subscript when it should be #132284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Apparently, FWIW, this happened for |
The following small change leaves previous C method slots unchanged in subclasses if not overridden (including diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index b92eaefc90d..69bcc32e7c0 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -11184,7 +11184,14 @@ update_one_slot(PyTypeObject *type, pytype_slotdef *p)
}
else {
use_generic = 1;
- generic = p->function;
+ if (generic == NULL && Py_IS_TYPE(descr, &PyMethodDescr_Type) &&
+ *ptr == ((PyMethodDescrObject *)descr)->d_method->ml_meth)
+ {
+ generic = *ptr;
+ }
+ else {
+ generic = p->function;
+ }
if (p->function == slot_tp_call) {
/* A generic __call__ is incompatible with vectorcall */
type_clear_flags(type, Py_TPFLAGS_HAVE_VECTORCALL); Subclass
to:
Rationale for the checks is as follows:
Passes all the tests but I don't have too much experience in this part of the code so there may be some other check or two still needed? Do you want this as a PR? |
That makes sense. Go ahead and make a PR. |
Uh oh!
There was an error while loading. Please reload this page.
A dict subclass which does not override
__getitem__
(likecollections.Counter
) should haveDict_Type.tp_as_mapping->mp_subscript
as itsPy_TYPE(lhs)->tp_as_mapping->mp_subscript
, but they are not the same.CC @ericsnowcurrently .
Linked PRs
The text was updated successfully, but these errors were encountered: