mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +00:00
bpo-37108: Support super with methods that use positional-only arguments (GH-13695)
This commit is contained in:
parent
c7f803b08e
commit
3a46d5c293
2 changed files with 15 additions and 1 deletions
|
|
@ -398,6 +398,20 @@ class PositionalOnlyTestCase(unittest.TestCase):
|
||||||
gen = f()
|
gen = f()
|
||||||
self.assertEqual(next(gen), (1, 2))
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -7807,7 +7807,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
"super(): no code object");
|
"super(): no code object");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (co->co_argcount == 0) {
|
if (co->co_posonlyargcount + co->co_argcount == 0) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"super(): no arguments");
|
"super(): no arguments");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue