Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

No validation on erroneous creation of 2 or more parameter variables (VAR_KEYWORD and VAR_POSITIONAL) in inspect.Signature #127610

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@ApostolFet

Description

@ApostolFet

Bug report

Bug description:

We can createinspect.Signature with two or more variable parameters, but this will be syntactically incorrect when defining the function manually:

importinspectparameters= [inspect.Parameter("args",kind=inspect.Parameter.VAR_POSITIONAL),inspect.Parameter("other_args",kind=inspect.Parameter.VAR_POSITIONAL),inspect.Parameter("kwargs",kind=inspect.Parameter.VAR_KEYWORD),inspect.Parameter("other_kwargs",kind=inspect.Parameter.VAR_KEYWORD),]signature=inspect.Signature(parameters)print(signature)

OUTPUT:

(*args, *other_args, **kwargs, **other_kwargs)

And naturally we get a syntax error when defining a function with such a signature:

deffunc(*args,*other_args,**kwargs,**other_kwargs):    ...

OUTPUT:

  File "/home/apostol_fet/inspect_signature.py", line 13    def func(*args, *other_args, **kwargs, **other_kwargs):                    ^SyntaxError: * argument may appear only once

Can we add validations for this case ininspect.Signature.__init__?
I would like to send a PR to fix this if it is not intended behavior.

CPython versions tested on:

3.12

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp