New submission from Antony Lee <anntzer....@gmail.com>:

Python 3.6.4

    In [15]: inspect.Parameter("foo", kind=inspect.Parameter.VAR_KEYWORD, 
default=42)
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    <ipython-input-15-7ed8c4fd15f3> in <module>()
    ----> 1 inspect.Parameter("foo", kind=inspect.Parameter.VAR_KEYWORD, 
default=42)

    /usr/lib/python3.6/inspect.py in __init__(self, name, kind, default, 
annotation)
    2442             if kind in (_VAR_POSITIONAL, _VAR_KEYWORD):
    2443                 msg = '{} parameters cannot have default 
values'.format(kind)
    -> 2444                 raise ValueError(msg)
    2445         self._default = default
    2446         self._annotation = annotation

    ValueError: 4 parameters cannot have default values

Note the "interesting" error message that starts with "4 parameters ..." (yes, 
I guess that inspect.Parameter == 4 internally...).

Probably just a matter of making the error f'{kind.name} parameters ...'.

----------
components: Library (Lib)
messages: 314764
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Confusing error message when constructing invalid inspect.Parameters
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33197>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to