Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a46d5c

Browse files
authored
bpo-37108: Support super with methods that use positional-only arguments (GH-13695)
1 parent c7f803b commit 3a46d5c

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Lib/test/test_positional_only_arg.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,20 @@ def f(a=1, /, b=2):
398398
gen = f()
399399
self.assertEqual(next(gen), (1, 2))
400400

401+
def test_super(self):
402+
403+
sentinel = object()
404+
405+
class A:
406+
def method(self):
407+
return sentinel
408+
409+
class C(A):
410+
def method(self, /):
411+
return super().method()
412+
413+
self.assertEqual(C().method(), sentinel)
414+
401415

402416
if __name__ == "__main__":
403417
unittest.main()

Objects/typeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7807,7 +7807,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
78077807
"super(): no code object");
78087808
return -1;
78097809
}
7810-
if (co->co_argcount == 0) {
7810+
if (co->co_posonlyargcount + co->co_argcount == 0) {
78117811
PyErr_SetString(PyExc_RuntimeError,
78127812
"super(): no arguments");
78137813
return -1;

0 commit comments

Comments
 (0)