Message413778
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! |
|
Date |
User |
Action |
Args |
2022-02-23 08:53:26 | ofey404 | set | recipients:
+ ofey404, ping, larry, yselivanov |
2022-02-23 08:53:26 | ofey404 | set | messageid: <1645606406.53.0.110614326369.issue46761@roundup.psfhosted.org> |
2022-02-23 08:53:26 | ofey404 | link | issue46761 messages |
2022-02-23 08:53:26 | ofey404 | create | |
|