summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/inspect.py2
-rw-r--r--Lib/test/test_inspect.py7
2 files changed, 7 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index b65bec7adf..e830eb64ca 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -2591,8 +2591,6 @@ class BoundArguments:
empty dict.
"""
arguments = self.arguments
- if not arguments:
- return
new_arguments = []
for name, param in self._signature.parameters.items():
try:
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 69ddb514d6..671e05a7b5 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -3324,6 +3324,13 @@ class TestBoundArguments(unittest.TestCase):
ba.apply_defaults()
self.assertEqual(list(ba.arguments.items()), [])
+ # Make sure a no-args binding still acquires proper defaults.
+ def foo(a='spam'): pass
+ sig = inspect.signature(foo)
+ ba = sig.bind()
+ ba.apply_defaults()
+ self.assertEqual(list(ba.arguments.items()), [('a', 'spam')])
+
class TestSignaturePrivateHelpers(unittest.TestCase):
def test_signature_get_bound_param(self):