classification
Title: IDLE:not able to complete the hashlib module
Type: behavior Stage: resolved
Components: IDLE, Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Ramchandra Apte, eric.araujo, ned.deily, python-dev, roger.serwy, terry.reedy
Priority: normal Keywords: patch

Created on 2012-02-03 16:00 by Ramchandra Apte, last changed 2012-02-05 19:34 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
issue13933.patch roger.serwy, 2012-02-04 16:28 review
Messages (10)
msg152531 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-02-03 16:00
No completion appears when I import hashlib in IDLE and type in "hashlib." and press Tab to complete.
With any other module it works.
msg152588 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-02-04 03:39
Ramchandra: what OS and Python version? Please always include in reports.

I verified on win7,3.2.2, with hashlib versus itertools, idlelib, heapq, trace. (On my new machine, popup is so fast I do not need <tab>.) In fact, 'hashlib.' and <tab> results in a tab to next tab position. ^<space> to <show completions> also does not work, but it does without the '.'. Some files (only builtins?) work without being imported. Everything seemed to work the same in an edit window.

hashlib.__all__ exists as a tuple. Modules without .__all__ also work.
Both cases are handled in idlelib.AutoComplete.fetch_completions().
I see nothing strange about hashlib.

Looking at idlelib.AutoComplete.py, I see other problems to fix.

"This extension can complete either attribute names of file names."
/of/or/, but ^<sp> in name brings up globals list with cursor at closest name to what one has entered. Are these handled elsewhere?

# This string includes all chars that may be in a file name (without a path
# separator)
FILENAME_CHARS = string.ascii_letters + string.digits + os.curdir + "._~#$:-"
# This string includes all chars that may be in an identifier
ID_CHARS = string.ascii_letters + string.digits + "_"

FILENAME_CHARS looks Windows specific. Both definitions are obsolete. IDLE should not separately define such things if at all possible.

But 'hash' is not in the file and I see little specific to the text context. Without being able to insert print calls to see what is and is not executed, I have no idea how to proceed.
msg152589 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-02-04 04:40
I am using Ubuntu 11.04 with Python 3.2.2 from the package reprositeries (binaries)
msg152633 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-02-04 16:28
Attached is a patch against 3.3a0 to fix the problem. The cause of the bug is that a tuple can not be sorted and calling .sort was raising a silenced exception. The patch explicitly converts __all__ to a list.
msg152635 - (view) Author: Roundup Robot (python-dev) Date: 2012-02-04 17:38
New changeset 741d4aaf7947 by Ned Deily in branch '2.7':
Issue #13933: IDLE auto-complete did not work with some imported
http://hg.python.org/cpython/rev/741d4aaf7947

New changeset 3e9a7fdf0498 by Ned Deily in branch '3.2':
Issue #13933: IDLE auto-complete did not work with some imported
http://hg.python.org/cpython/rev/3e9a7fdf0498

New changeset 443772a82dcd by Ned Deily in branch 'default':
Issue #13933: merge
http://hg.python.org/cpython/rev/443772a82dcd
msg152636 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-02-04 17:40
Roger's patch solves the problem.  Thanks!  Applied to 2.7 (for 2.7.3), 3.2 (for 3.2.3), and default (for 3.3).
msg152642 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-02-04 20:17
Thank you both. I saw the answer (hashlib.__all__ is, unusally, a tuple) but did not see how it was the answer.
msg152673 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-05 10:17
BTW I wonder if setting __all__ to something but a list is valid.  I think I ran into a similar bug once and fixing __all__ fixed it.  The IDLE robustness fix is probably a good thing, but maybe we should also check the stdlib’s __all__s and the docs.
msg152700 - (view) Author: Roundup Robot (python-dev) Date: 2012-02-05 19:33
New changeset 2b93ee675ec4 by Terry Jan Reedy in branch '2.7':
#13933 refine patch using 'new' builtin
http://hg.python.org/cpython/rev/2b93ee675ec4

New changeset d8f988b0c959 by Terry Jan Reedy in branch '3.2':
#13933 refine patch using 'new' builtin
http://hg.python.org/cpython/rev/d8f988b0c959

New changeset 60beb14636b7 by Terry Jan Reedy in branch 'default':
Merge with 3.2
http://hg.python.org/cpython/rev/60beb14636b7
msg152701 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-02-05 19:34
6.11 Import statement says " __all__; if defined, it must be a sequence of strings which are names defined or imported by that module."

I am tempted to open an issue to change 'sequence' to 'list', or even 'sorted sequence', but that is difficult to enforce.
History
Date User Action Args
2012-02-05 19:34:10terry.reedysetmessages: + msg152701
2012-02-05 19:33:25python-devsetmessages: + msg152700
2012-02-05 10:17:58eric.araujosetnosy: + eric.araujo
messages: + msg152673
2012-02-04 20:17:51terry.reedysetmessages: + msg152642
2012-02-04 17:40:32ned.deilysetstatus: open -> closed
2012-02-04 17:40:12ned.deilysetnosy: + ned.deily
messages: + msg152636

resolution: fixed
stage: resolved
2012-02-04 17:38:46python-devsetnosy: + python-dev
messages: + msg152635
2012-02-04 16:28:02roger.serwysetfiles: + issue13933.patch
keywords: + patch
messages: + msg152633
2012-02-04 04:40:02Ramchandra Aptesetmessages: + msg152589
2012-02-04 03:39:57terry.reedysetnosy: + roger.serwy, terry.reedy

messages: + msg152588
versions: + Python 3.3
2012-02-03 16:00:05Ramchandra Aptecreate