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: rlcompleter can't autocomplete members of callable objects
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: facundobatista Nosy List: dieresys, facundobatista, gpolo, pitrou
Priority: normal Keywords:

Created on 2008-07-17 20:42 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg69905 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-07-17 20:42
This is a regression caused by #449227. When typing e.g. "int." and then
pressing tab, none of the int members is proposed. It worked until just
before r64664.
msg69911 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-07-17 21:52
This is somewhat obscure to notice but the problem is towards that
getattr on attr_matches. For "int" specifically, it will try to get the
attribute '__abstractmethods__' (which is a member of int.__class__) and
will raise an AttributeError but then the exception is discarded by the
readline module.
A workaround is to change that getattr to:

try:
    val = getattr(object, word)
except AttributeError:
    continue
msg69933 - (view) Author: Manuel Muradás (dieresys) Date: 2008-07-18 05:22
Oops, you are right. If that is the way we should handle this
regression, I could upload a patch. I also thought we could use
"hasattr", but that means using "getattr" twice. Something like:

if word[:n] == attr and word != "__builtins__" and hasattr(object, word):
    val = getattr(object, word)

What do you think about it?
msg70105 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-07-21 13:06
I don't understand.

I tried the following:

Python 2.6b2+ (trunk:65167M, Jul 21 2008, 09:51:48) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rlcompleter
>>> import readline
>>> readline.parse_and_bind("tab: complete")

Then I wrote "int". Then I pressed TAB. Nothing happened. I pressed TAB
again, and the following appeared:

>>> int
int(     intern(  

To me this is the expected behaviour: if the system has two alternatives
(in this case it does not if it should follow with "(" or "e"), don't
continue with the first tab, and then show all the options with the
second tab (I'm used to this in bash).

Is this wrong according to you?
msg70107 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-07-21 13:10
Selon Facundo Batista <report@bugs.python.org>:
>
> Then I wrote "int". Then I pressed TAB. Nothing happened. I pressed TAB
> again, and the following appeared:
>
> >>> int
> int(     intern(

This is not the point. The problem is when you type "int.", then press TAB twice
and it doesn't show the list of int members.
msg70110 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-07-21 14:28
Ah, sorry, missed that point.

Ok, I included this change and now it works ok.

Also worked a little that code (change the name of the variable
"object", used extend() for a list instead of adding to itself, and
removed a comparison from a loop).

Commited in r65168.
History
Date User Action Args
2022-04-11 14:56:36adminsetgithub: 47646
2008-07-21 14:28:44facundobatistasetstatus: open -> closed
resolution: fixed
messages: + msg70110
2008-07-21 13:10:38pitrousetmessages: + msg70107
2008-07-21 13:06:28facundobatistasetmessages: + msg70105
2008-07-20 20:49:05georg.brandlsetassignee: facundobatista
2008-07-18 05:22:51dieresyssetnosy: + dieresys
messages: + msg69933
2008-07-17 21:52:51gpolosetnosy: + gpolo
messages: + msg69911
2008-07-17 20:42:08pitroucreate