This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ofey404
Recipients larry, ofey404, ping, yselivanov
Date 2022-02-23.08:53:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645606406.53.0.110614326369.issue46761@roundup.psfhosted.org>
In-reply-to
Content
Hello, I am new to cpython project and want to help.

I dig into `follow_wrapper_chains` feature and found it really interesting.

In `inspect.signature()`, the conversion of `functools.partial` object's signature is made when going down the unwrap chain.

Relevant code: https://github.com/python/cpython/blob/288af845a32fd2a92e3b49738faf8f2de6a7bf7c/Lib/inspect.py#L2467

So, there is an inconsistent assumption which cause the problem:

- `inspect.signature()` handle `functools.partial` object it met specially.
- `functools.update_wrapper()` just treat `functools.partial` object as a normal decorator and ignore it.
  
After calling `functools.update_wrapper()`, a new (wrong) signature is constructed, and it covers the original (right) process.

That's why `inspect.signature()` returns the *original* function's signature, not the *wrapped* function's signature.

In my humble opinion, A sane solution might be that: let the `functools.update_wrapper` respect the `functools.partial` object in the similar way of `inspect.signature()`.

I'm working on a pull request to express my idea more clearly, any help is welcome!
History
Date User Action Args
2022-02-23 08:53:26ofey404setrecipients: + ofey404, ping, larry, yselivanov
2022-02-23 08:53:26ofey404setmessageid: <1645606406.53.0.110614326369.issue46761@roundup.psfhosted.org>
2022-02-23 08:53:26ofey404linkissue46761 messages
2022-02-23 08:53:26ofey404create