Skip to content

Commit

Permalink
bpo-37108: Support super with methods that use positional-only argume…
Browse files Browse the repository at this point in the history
…nts (GH-13695)
  • Loading branch information
pablogsal committed May 31, 2019
1 parent c7f803b commit 3a46d5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Lib/test/test_positional_only_arg.py
Expand Up @@ -398,6 +398,20 @@ def f(a=1, /, b=2):
gen = f()
self.assertEqual(next(gen), (1, 2))

def test_super(self):

sentinel = object()

class A:
def method(self):
return sentinel

class C(A):
def method(self, /):
return super().method()

self.assertEqual(C().method(), sentinel)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion Objects/typeobject.c
Expand Up @@ -7807,7 +7807,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
"super(): no code object");
return -1;
}
if (co->co_argcount == 0) {
if (co->co_posonlyargcount + co->co_argcount == 0) {
PyErr_SetString(PyExc_RuntimeError,
"super(): no arguments");
return -1;
Expand Down

0 comments on commit 3a46d5c

Please sign in to comment.