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.

Title: IDLE leaks `_` into hint box
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.10
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: serhiy.storchaka, terry.reedy, wyz23x2
Priority: normal Keywords:

Created on 2020-08-14 08:51 by wyz23x2, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg375383 - (view) Author: wyz23x2 (wyz23x2) * Date: 2020-08-14 08:51
1. Open shell and enter an expression, say 1+1.
2. Create a new file and save.
3. Enter a letter and press Tab. `_` appears in the box.
msg375420 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-08-14 17:12
I cannot reproduce from the description.  More details: OS and maybe version, exact Python version (only most recent releases count as completions have been touched recently), exact key presses and click in which windows.  Step 2 should be irrelevant.  Step 3 gives me a box with keywords and builtins.  Backspace and hitting '_' adds entries beginning with '_', including '_' when defined.
msg375426 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-08-14 18:57
I think that I understood what is the issue.

1. Open the IDLE editor, type "foo" and press <Ctrl-Space>. The pop-up list does not contain "foo".
2. Switch to the IDLE shell, type "foo = 1" and press <Enter>.
3. Switch back to the IDLE editor (the cursor points after "foo") and press <Ctrl-Space> again. The pop-up list contains now "foo".

The problem is that the completion list for editor contains names from the shell instead of only from builtins. When you run the code from the editor, names from the shell are not automatically available.

It can be a feature if you use the same star-import in the shell and editor, but it can also be considered as a bug.
msg375456 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-08-15 10:58
The global completion list for Shell or Editor comprises keywords (recently added), builtins, and global names bound by code executed in the current subprocess.  The doc recommends restarting the subprocess when editing so that the global names are those resulting from the code being edited rather than code enter in Shell.  (I an trying to make this even clearer in the doc.)

wyz23x2 appears to claim that at least one leading underscore name, in particular '_', appeared in the list without having ever entered '_' as the prefix to be completed.  That would be a bug.  (_ names appear after ZeroDivisionError.)  This might have happened in the past, but I do not see this in current IDLE.  Without further info, I will close this as 'not a bug'. 

If '_' appeared alone, without the builtins, that would be a deeper bug.
Date User Action Args
2022-04-11 14:59:34adminsetgithub: 85721
2020-09-01 16:50:10terry.reedysetstatus: open -> closed
resolution: not a bug
stage: resolved
2020-08-15 10:58:27terry.reedysetmessages: + msg375456
versions: + Python 3.10, - Python 3.8, Python 3.9
2020-08-14 18:57:56serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg375426
2020-08-14 17:12:29terry.reedysetmessages: + msg375420
2020-08-14 08:51:48wyz23x2create