This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: BoundArguments.apply_defaults doesn't handle empty arguments
Type: behavior Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: yselivanov Nosy List: Frederick Wagner, martin.panter, python-dev, yselivanov
Priority: normal Keywords: patch

Created on 2016-02-12 03:33 by Frederick Wagner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
0001-Make-apply_defaults-work-for-empty-arguments.patch Frederick Wagner, 2016-02-12 03:33 review
Messages (6)
msg260157 - (view) Author: Frederick Wagner (Frederick Wagner) * Date: 2016-02-12 03:33
[First-time contributor, feedback appreciated.]

Found and fixed some unexpected behavior in inspect.BoundArguments.apply_defaults. Simplest explanation is the following test that I added:

        # 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')])

I've included the patch file; is there anything else I can do?
msg260159 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-02-12 04:05
Patch looks good to me
msg260180 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-02-12 14:03
Hi Frederick, the patch looks good.  Thanks for reporting this!  Could you please sign the contributor agreement so that I can commit your patch?
msg260371 - (view) Author: Frederick Wagner (Frederick Wagner) * Date: 2016-02-17 00:22
All right, looks like I have the asterisk now! Looking forward to officially contributing to the Python standard library :)
msg261119 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-02 16:09
New changeset 94879997ea5f by Yury Selivanov in branch '3.5':
inspect: Fix BoundArguments.apply_defaults to handle empty arguments
https://hg.python.org/cpython/rev/94879997ea5f

New changeset 779a0d51f7e2 by Yury Selivanov in branch 'default':
Merge 3.5 (issue #26347)
https://hg.python.org/cpython/rev/779a0d51f7e2
msg261120 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-03-02 16:10
Merged. Thank you Frederick for your contribution!
History
Date User Action Args
2022-04-11 14:58:27adminsetgithub: 70535
2016-03-02 16:10:27yselivanovsetstatus: open -> closed
resolution: fixed
messages: + msg261120

stage: patch review -> resolved
2016-03-02 16:09:50python-devsetnosy: + python-dev
messages: + msg261119
2016-02-17 00:22:40Frederick Wagnersetmessages: + msg260371
2016-02-12 14:03:18yselivanovsetassignee: yselivanov

messages: + msg260180
nosy: + yselivanov
2016-02-12 04:05:54martin.pantersetnosy: + martin.panter

messages: + msg260159
stage: patch review
2016-02-12 03:33:09Frederick Wagnercreate