[New-bugs-announce] [issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments
Serhiy Storchaka
report at bugs.python.org
Thu Apr 21 15:23:41 EDT 2016
New submission from Serhiy Storchaka:
itemgetter(), attrgetter() and methodcaller() objects require one argument. They raise TypeError if less or more than one positional argument is provided. But they totally ignore any keyword arguments.
>>> import operator
>>> f = operator.itemgetter(1)
>>> f('abc', spam=3)
'b'
>>> f = operator.attrgetter('index')
>>> f('abc', spam=3)
<built-in method index of str object at 0xb7172b20>
>>> f = operator.methodcaller('upper')
>>> f('abc', spam=3)
'ABC'
Proposed patch makes these objects raise TypeError if keyword arguments are provided.
----------
components: Extension Modules
files: operator_getters_kwargs.patch
keywords: patch
messages: 263933
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: itemgetter/attrgetter/methodcaller objects ignore keyword arguments
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42560/operator_getters_kwargs.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26822>
_______________________________________
More information about the New-bugs-announce
mailing list