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.

classification
Title: help() on a property descriptor launches interactive help
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: belopolsky, jackdied, terry.reedy
Priority: low Keywords: patch

Created on 2010-06-29 18:32 by jackdied, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue9118.diff belopolsky, 2010-07-01 04:02 review
issue9118a.diff belopolsky, 2010-07-04 04:11 review
Messages (7)
msg108928 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2010-06-29 18:32
ython 2.7b2+ (trunk:81337, May 19 2010, 12:16:22) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class X(object):
...   @property
...   def foo(self): pass
... 
>>> help(X.foo.fset)

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> ^D
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
>>>
msg109030 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-01 04:02
This is simply because X.foo.fset is None and help(None) is the same as help().  Now, I think help(None) should print help on None object rather than start interactive help.  Please consider attached patch.
msg109204 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-04 03:55
I agree that help(None) should return help on None but suggest a change to the patch.

I understand that the point of changing
-    def __call__(self, request=None):
to the somewhat opaque
+    def __call__(self, *args):
+        try:
+            request, = args
+        except ValueError:
is to make help() work the same as now without defaulting request to None. However, I believe that it will change help(1,2) to being the same as help() instead raising TypeError. I do not think that that API change is desirable. This can be avoided by instead creating a private sentinel. The alternate replacement would be

+    __GoInteractive = object()
+    def __call__(self, request=__GoInteractive):
+        if request is not __GoInteractive:
-        if request is not None:

with the rest of code the unchanged.
msg109205 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-04 04:11
Yes, I realized that 2+ arguments would be equivalent to none, but was too lazy to handle that case. (Falling into interactive help may actually be better than an error message for some users.) Terry's solution is certainly better.  Attaching issue9118a.diff.
msg109239 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-04 17:06
Committed in r82547. I am leaving it open to decide whether this is a 3.1-backport candidate.   Also I am not sure this is NEWS-worthy.


Jack,

Does this address your issue?  Note that

>>> help(X.foo.fset)

will still not return help on X.foo, but it will make it obvious that X.foo.fset is None.
msg109250 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-04 18:07
The doc says that help takes one optional arg:
No arg: interactive help system
String: interpret as name of something
Any other object: help page for that object
[by implication, multiple args: TypeError]

Not returning help for None is a bug, so I say yes, backport, including to 2.6/7 if they have same bug. I think the OP's example, which turns on the fact that None is an object that can be attached to any target, and not just a name, illustrates the bugginess of the current behavior.

If NEWS includes a detailed list of bugfixes, then this could be included. If not, no.
msg126011 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-01-11 15:36
Backported to 3.1 (r87934) and 2.7 (r87935).
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53364
2011-01-11 15:36:02belopolskysetstatus: open -> closed

messages: + msg126011
resolution: accepted -> fixed
nosy: terry.reedy, belopolsky, jackdied
2010-07-04 18:07:29terry.reedysetmessages: + msg109250
2010-07-04 17:06:39belopolskysetstage: commit review -> resolved
messages: + msg109239
versions: + Python 3.1
2010-07-04 04:11:51belopolskysetfiles: + issue9118a.diff
versions: + Python 3.2, - Python 2.6, Python 2.7
messages: + msg109205

assignee: belopolsky
resolution: accepted
stage: patch review -> commit review
2010-07-04 03:55:13terry.reedysetnosy: + terry.reedy
messages: + msg109204
2010-07-01 04:02:47belopolskysetfiles: + issue9118.diff

nosy: + belopolsky
messages: + msg109030

keywords: + patch
stage: needs patch -> patch review
2010-06-29 18:32:48jackdiedcreate