Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Bug report
Bug description:
I tried searching for something related but I could not find exactly this case withsuper. Maybe I missed… so posting it here.
Following code works fine:
classA:deffoo(self):return1classB(A):deffoo(self):return [super().foo()for_inrange(10)]print(B().foo())
But if you modify it to be like this:
classA:deffoo(self):return1classB(A):deffoo(self):returnlist(super().foo()for_inrange(10))print(B().foo())
you will get following error:
TypeError:super(type,obj):objmustbeaninstanceorsubtypeoftype
Before#101441 ,[super().foo() for _ in range(10)] would cause the same error but it was fixed implicitly byPEP709.
You can fix this yourself by specifying type and instance insuper():
classA:deffoo(self):return1classB(A):deffoo(self):returnlist(super(B,self).foo()for_inrange(10))print(B().foo())
If you decide that fixing this makes sense, can I work on fixing it? To me it makes sense (if you decide to leave it as it is) at least to give some kind of warning or error that in this case you should explicitly provide type and instance tosuper, because it is quite confusing why user gets this error as semantically this is valid and should work
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, macOS