mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
Issue #17071: Signature.bind() now works when one of the keyword arguments is named `self
`.
This commit is contained in:
parent
c5b75db5de
commit
bd41d1b14c
3 changed files with 17 additions and 4 deletions
|
@ -2241,6 +2241,16 @@ class TestSignatureBind(unittest.TestCase):
|
|||
with self.assertRaisesRegex(TypeError, "parameter is positional only"):
|
||||
self.call(test, a_po=1, b_po=2)
|
||||
|
||||
def test_signature_bind_with_self_arg(self):
|
||||
# Issue #17071: one of the parameters is named "self
|
||||
def test(a, self, b):
|
||||
pass
|
||||
sig = inspect.signature(test)
|
||||
ba = sig.bind(1, 2, 3)
|
||||
self.assertEqual(ba.args, (1, 2, 3))
|
||||
ba = sig.bind(1, self=2, b=3)
|
||||
self.assertEqual(ba.args, (1, 2, 3))
|
||||
|
||||
|
||||
class TestBoundArguments(unittest.TestCase):
|
||||
def test_signature_bound_arguments_unhashable(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue