[New-bugs-announce] [issue30878] The staticmethod doesn't properly reject keyword arguments

Kay Hayen report at bugs.python.org
Sat Jul 8 03:00:06 EDT 2017


New submission from Kay Hayen:

Check out this:

python3.6 -c "staticmethod(function=1)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: staticmethod expected 1 arguments, got 0

python3.6 -c "staticmethod()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: staticmethod expected 1 arguments, got 0

python3.6 -c "staticmethod(f=1)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: staticmethod expected 1 arguments, got 0

I believe Python 2.7 behaves the same.

What should happen is more like this:

python3.6 -c "range(f=1)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: range() does not take keyword arguments

While statically optimizing, I came across this as a first. At least "classmethod" behaves the same. I suppose it is because these are not intended for manual use anymore.

I would recommend to fix up the argument parsing to either indicate its rejection of keyword arguments, or to accept "function = " for input (preferred).

Thanks,
Kay Hayen

----------
components: Interpreter Core
messages: 297946
nosy: kayhayen
priority: normal
severity: normal
status: open
title: The staticmethod doesn't properly reject keyword arguments
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30878>
_______________________________________


More information about the New-bugs-announce mailing list