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 <[email protected]>
<http://bugs.python.org/issue26822>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com