Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f3ef06a7
Commit
f3ef06a7
authored
Oct 15, 2019
by
Pablo Galindo
Committed by
GitHub
Oct 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38478: Correctly handle keyword argument with same name as positional-only parameter (GH-16800)
parent
eb1dda2b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
Lib/inspect.py
Lib/inspect.py
+1
-1
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+10
-0
Misc/NEWS.d/next/Library/2019-10-15-11-37-57.bpo-38478.A87OPO.rst
...S.d/next/Library/2019-10-15-11-37-57.bpo-38478.A87OPO.rst
+3
-0
No files found.
Lib/inspect.py
View file @
f3ef06a7
...
@@ -2960,7 +2960,7 @@ class Signature:
...
@@ -2960,7 +2960,7 @@ class Signature:
arguments
[
param
.
name
]
=
tuple
(
values
)
arguments
[
param
.
name
]
=
tuple
(
values
)
break
break
if
param
.
name
in
kwargs
:
if
param
.
name
in
kwargs
and
param
.
kind
!=
_POSITIONAL_ONLY
:
raise
TypeError
(
raise
TypeError
(
'multiple values for argument {arg!r}'
.
format
(
'multiple values for argument {arg!r}'
.
format
(
arg
=
param
.
name
))
from
None
arg
=
param
.
name
))
from
None
...
...
Lib/test/test_inspect.py
View file @
f3ef06a7
...
@@ -3573,6 +3573,16 @@ class TestSignatureBind(unittest.TestCase):
...
@@ -3573,6 +3573,16 @@ class TestSignatureBind(unittest.TestCase):
iterator
=
iter
(
range
(
5
))
iterator
=
iter
(
range
(
5
))
self
.
assertEqual
(
self
.
call
(
setcomp_func
,
iterator
),
{
0
,
1
,
4
,
9
,
16
})
self
.
assertEqual
(
self
.
call
(
setcomp_func
,
iterator
),
{
0
,
1
,
4
,
9
,
16
})
def
test_signature_bind_posonly_kwargs
(
self
):
def
foo
(
bar
,
/
,
**
kwargs
):
return
bar
,
kwargs
.
get
(
bar
)
sig
=
inspect
.
signature
(
foo
)
result
=
sig
.
bind
(
"pos-only"
,
bar
=
"keyword"
)
self
.
assertEqual
(
result
.
kwargs
,
{
"bar"
:
"keyword"
})
self
.
assertIn
((
"bar"
,
"pos-only"
),
result
.
arguments
.
items
())
class
TestBoundArguments
(
unittest
.
TestCase
):
class
TestBoundArguments
(
unittest
.
TestCase
):
def
test_signature_bound_arguments_unhashable
(
self
):
def
test_signature_bound_arguments_unhashable
(
self
):
...
...
Misc/NEWS.d/next/Library/2019-10-15-11-37-57.bpo-38478.A87OPO.rst
0 → 100644
View file @
f3ef06a7
Fixed a bug in :meth:`inspect.signature.bind` that was causing it to fail
when handling a keyword argument with same name as positional-only parameter.
Patch by Pablo Galindo.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment