[New-bugs-announce] [issue19140] inspect.Signature.bind() inaccuracies

Yann Kaiser report at bugs.python.org
Tue Oct 1 22:50:06 CEST 2013

New submission from Yann Kaiser:

A pair of inconsistencies I've found using Signature.bind:

(<a>=0).bind() -*> TypeError
Letting the default value of a positional-only parameter be used raises a TypeError with message that 'a' was passed by name.

(a, *args).bind(a=0, args=1) -> BoundArguments({'a': 0, 'args': 1})
Should positional arguments not be enough for bind() to reach the parameter before *args, bind() will process the *args parameter while looking for named arguments, and eventually bind the *args parameter to any named argument for it, instead of leaving that named argument for **kwargs or erroring out.

I've attached a patch that tests and fixes both issues.

I've taken the liberty of extending test_inspect.TestSignatureBind.test_signature_bind_positional_only as it already did all the setup needed but overlooked to check the condition where a defaulted positional-only parameter is left out.

components: Library (Lib)
files: sig_bind_posodefa_varargs.patch
keywords: patch
messages: 198806
nosy: epsy
priority: normal
severity: normal
status: open
title: inspect.Signature.bind() inaccuracies
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31940/sig_bind_posodefa_varargs.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list