Skip to content

functools.update_wrapper does not work with type #119011

Closed
@nikola-benes

Description

@nikola-benes

Bug report

Bug description:

from functools import update_wrapper

def my_type(*args): pass

t = update_wrapper(my_type, type)

This works on Python ≤ 3.11, and I think this is expected because the docs for update_wrapper claim that it may be used with callables other than functions.

However, with 3.12, I get

TypeError: __type_params__ must be set to a tuple

(Similarly for functools.wraps.)

The problem is that update_wrapper includes __type_params__ by default (which is undocumented, see related issue) and type.__type_params__ is a descriptor.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions