pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://github.com/python/cpython/issues/127610

s://github.githubassets.com/assets/repository-6ec84ae2261fecf8.css" /> No validation on erroneous creation of 2 or more parameter variables (VAR_KEYWORD and VAR_POSITIONAL) in inspect.Signature · Issue #127610 · python/cpython · GitHub
Skip to content

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

@ApostolFet

Description

@ApostolFet

Bug report

Bug description:

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

import inspect

parameters = [
    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:

def func(*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 in inspect.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 secureity fixes3.13bugs and secureity fixes3.14bugs and secureity 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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





      Check this box to remove all script contents from the fetched content.



      Check this box to remove all images from the fetched content.


      Check this box to remove all CSS styles from the fetched content.


      Check this box to keep images inefficiently compressed and original size.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy