Skip to content

types.FunctionType is missing kwdefaults from the constructor #112640

Description

@sobolevn

Feature or enhancement

@classmethod
function.__new__ as func_new
code: object(type="PyCodeObject *", subclass_of="&PyCode_Type")
a code object
globals: object(subclass_of="&PyDict_Type")
the globals dictionary
name: object = None
a string that overrides the name from the code object
argdefs as defaults: object = None
a tuple that specifies the default argument values
closure: object = None
a tuple that supplies the bindings for free variables
Create a function object.

It is rather strange to have defaults, but not kwdefaults.
I propose adding kwdefaults as the last parameter.

Linked PRs

Activity

  1. added
    type-featureA feature request or enhancement
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    3.13only security fixes
    on Dec 3, 2023
  2. self-assigned this
    on Dec 3, 2023
  3. added a commit that references this issue on Dec 3, 2023
  4. Gobot1234 commented on Dec 3, 2023

    @Gobot1234
    Contributor

    Should it also have type_params?

  5. sobolevn commented on Dec 3, 2023

    @sobolevn
    MemberAuthor

    I don't think that setting __annotations__ and __type_params__ is common enough.
    I think that using .__annotations__ = ... and .__type_params__ = ... can solve this. However, __kwdefaults__ is different, because it comes in pair with __defaults__ which is already present.

  6. added a commit that references this issue on Jan 11, 2024
  7. added a commit that references this issue on Jan 22, 2024
  8. added a commit that references this issue on Feb 11, 2024
  9. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.13only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions