diff options
author | Apostol Fet <90645107+ApostolFet@users.noreply.github.com> | 2024-12-08 10:05:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-08 10:05:15 (GMT) |
commit | 1503fc8f88d4903e61f76a78a30bcd581b0ee0cd (patch) | |
tree | c42346ad7d4db76f908062eb2a6bd0948c605772 /Lib/inspect.py | |
parent | 70154855cf698560dd9a5e484a649839cd68dc7c (diff) | |
download | cpython-1503fc8f88d4903e61f76a78a30bcd581b0ee0cd.zip cpython-1503fc8f88d4903e61f76a78a30bcd581b0ee0cd.tar.gz cpython-1503fc8f88d4903e61f76a78a30bcd581b0ee0cd.tar.bz2 |
gh-127610: Added validation for more than one var-positional and var-keyword parameters in inspect.Signature (GH-127657)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index e3f74e9f..b7d8271 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2943,11 +2943,19 @@ class Signature: params = OrderedDict() top_kind = _POSITIONAL_ONLY seen_default = False + seen_var_parameters = set() for param in parameters: kind = param.kind name = param.name + if kind in (_VAR_POSITIONAL, _VAR_KEYWORD): + if kind in seen_var_parameters: + msg = f'more than one {kind.description} parameter' + raise ValueError(msg) + + seen_var_parameters.add(kind) + if kind < top_kind: msg = ( 'wrong parameter order: {} parameter before {} ' |