- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue29940
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.
Created on 2017-03-29 15:41 by samwyse, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 12915 | closed | eamanu, 2019-04-22 20:25 | |
| PR 22390 | closed | eamanu, 2020-09-23 20:28 | |
| Messages (4) | |||
|---|---|---|---|
| msg290782 - (view) | Author: Samwyse (samwyse) * | Date: 2017-03-29 15:41 | |
The help(obj) function uses the type of obj to create its result. This is less than helpful when requesting help on a wrapped object. Since 3.5, inspect.signature() and inspect.from_callable() have a follow_wrapped option to get around similar issues. Adding the option to help() would prevent surprising behavior while still allowing current behavior to be used when needed. See http://stackoverflow.com/a/17705456/603136 for more. |
|||
| msg377503 - (view) | Author: Tal Einat (taleinat) * ![]() |
Date: 2020-09-25 19:14 | |
To clarify, to my understanding the issue here is that when using a class as a decorator, and copying the wrapped function's __doc__ to self.__doc__ in __init__, help() will pick up the wrapper class's __doc__ rather than the instance's __doc__.
For example:
class Deco:
"A decorator."
def __init__(self, func):
functools.update_wrapper(self, func)
def __call__(self, *args, **kwargs):
pass
@Deco
def double(n):
"A function."
return n * 2
help(double) will show "A decorator." rather than "A function." despite the use of functools.update_wrapper().
|
|||
| msg377513 - (view) | Author: Emmanuel Arias (eamanu) * | Date: 2020-09-26 00:24 | |
Hi @taleinat, Seems tha the wrapped func already has the __doc__ (in this case) copied. following your example: >>> double <test.Deco object at 0x7fe8d1fd5b20> >>> double.__doc__ 'A function' so help(double) will print correctly the double doc. |
|||
| msg377518 - (view) | Author: Tal Einat (taleinat) * ![]() |
Date: 2020-09-26 06:54 | |
The issue was not that __doc__ was not copied, but that help() would use the class's __doc__ when called on an instance, even if that instance had its own __doc__. See the StackOverflow question for another example. You will not see this issue with the latest master branch, because it has already been resolved by PR GH-19479, as described and discussed in issue40257. Closing as "out of date". |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:44 | admin | set | github: 74126 |
| 2020-09-26 06:54:20 | taleinat | set | status: open -> closed resolution: out of date messages: + msg377518 stage: patch review -> resolved |
| 2020-09-26 00:24:49 | eamanu | set | messages: + msg377513 |
| 2020-09-25 19:14:22 | taleinat | set | nosy:
+ taleinat messages: + msg377503 |
| 2020-09-23 20:28:01 | eamanu | set | pull_requests: + pull_request21431 |
| 2019-04-22 20:25:09 | eamanu | set | keywords:
+ patch stage: patch review pull_requests: + pull_request12841 |
| 2019-04-22 17:57:25 | eamanu | set | nosy:
+ eamanu |
| 2019-04-22 07:25:49 | xtreak | set | nosy:
+ rhettinger versions: + Python 3.8, - Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7 |
| 2017-03-29 15:41:05 | samwyse | create | |


