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: IDLE: not executing commands from shell, error with default keybinding for Return
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: asvetlov Nosy List: ankit615, asvetlov, ned.deily, python-dev, roger.serwy
Priority: normal Keywords: patch

Created on 2012-03-26 04:41 by ankit615, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
config-extensions.cfg ankit615, 2012-03-28 18:15
config-main.cfg ankit615, 2012-03-28 18:16
issue14409.patch roger.serwy, 2012-03-28 19:10 review
Messages (15)
msg156798 - (view) Author: Ankit Agrawal (ankit615) Date: 2012-03-26 04:41
I'm trying to run python (version 2.7.2) on my computer (windows vista 32bit). It's always worked until now when Idle just does not respond to any commands.

Any commands entered (even very simple ones) have no output/do not get computed! See image: http://dl.dropbox.com/u/32209936/image%20idle%20Idle.jpg

Python works fine when I run it using command line though! See image:
http://dl.dropbox.com/u/32209936/image%20python%20command%20line.jpg

I've tried re-installing it a few times but it just doesn't help! Also tried running it from C:\Python27\Lib\idlelib\idle.py and I get the following message before the same unresponsive IDLE pops up again! See image: http://dl.dropbox.com/u/32209936/image%20python%20warnings.jpg

Checked the file config-keys.def under C:\Python27\Lib\idlelib and its permissions. Also checked all other config-*.def files in this folder.
msg156800 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-03-26 07:39
Hi Ankit,

It looks like your configuration files for IDLE has a bug. Can you try renaming your .idlerc directory (likely located in your home directory) to something else and then retry using IDLE?

Also, can you post your existing config-main.cfg and config-keys.cfg? This may help in making IDLE more robust against this error in the future.
msg156877 - (view) Author: Ankit Agrawal (ankit615) Date: 2012-03-26 22:55
Hello Roger,

Thanks much for the comment. What you're saying seems right! I've tried renaming the .idlerc folder (which I did find in my home folder) but this just gives me an error. See Image: http://dl.dropbox.com/u/32209936/rename%20problem.jpg

After a few tries I wasn't sure how to handle this so I simply removed the folder from my home directory to see if it made a difference which to my delight, fixed the problem (to seems to be working so far)! 

At the same time, IDLE seems to have created a new one for itself and I wanted to check whether I need to add any files from the .idlerc folder I removed to the new one. 

I'd be glad to post my existing files,however I only seem to have config-extensions.cfg and the file named "config-keys.cfg" seems to be missing from my folder. I was wondering if this would be of any help?
msg156878 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-03-26 23:08
I'm glad to hear that IDLE now works. IDLE will recreate .idlerc if it doesn't exist and populate it with your settings.

If you can, please post your original, broken .cfg files. I'll try to decipher the cause of the original problem.
msg156994 - (view) Author: Ankit Agrawal (ankit615) Date: 2012-03-28 18:15
Please find attached, the  original .cfg files that I was found in my idlerc folder. I hope this proves helpful. If you need any other information I'd be glad to help.
msg156995 - (view) Author: Ankit Agrawal (ankit615) Date: 2012-03-28 18:16
Another cfg file from the original .idlerc folder
msg157000 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-03-28 19:10
Thank you for the configuration files. It helped with finding the bug.

The default key bindings in configHandler.py is incorrect for <<newline-and-indent>> which caused the problem Ankit experienced.  This problem affects the 2.7 and 3.3 series. 

Attached is a patch against 3.3 (and 2.7) to fix the issue.
msg157007 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-03-28 19:59
Roger, I notice that the line your patch modifies in configHandler.py has been unchanged for years and is the same in older Python versions.  My impression from Ankit's description is that this is a new problem.  What's different or am I misunderstanding something?
msg157009 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-03-29 03:13
Ned, the buggy default keybinding for <<newline-and-indent>> requires that Key-Return and then Key-KP_Enter be pressed before the virtual event triggers. This happens because both key events are present in a single string. The correct behavior requires each key event be listed in a separate string in a list. (See <<copy>> for an example). MultiCall.py has code (event_add) that iterates over the list and binds each key to an event.

This bug is also present in 2.3.5. (I just downloaded and tested it on XP.)
msg157041 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-03-29 13:21
I agree with Roger's patch. 
But I'm pretty sure Ankit had another problem just because IDLE shell works for everyone without that patch.
msg157054 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-03-29 14:59
IDLE contains keyboard configuration in config-keys.def (Mac, Windows, UNIX) and in configHandler.py. 

GetCoreKeys contains the "keyBindings" dict which has fall-back values in case the given key set is missing values (a warning is printed). Ankit's screenshot contains these warning messages.

GetKeyBinding is a helper function that splits a string containing multiple key bindings. Read the commented header in config-keys.def to see why this is so. 

The fall-back values in keyBindings do not pass through the GetKeyBinding function, and thus "<Key-Return> <Key-KP_enter>" does not get split.

Everyone else uses IDLE's prepackaged key bindings as a starting point for creating custom key maps. The key maps from config-keys.def already passed through GetKeyBinding. This is why <Return> works for everyone else.
msg157059 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-29 16:01
New changeset 26b2407c644e by Andrew Svetlov in branch '3.2':
Issue #14409: IDLE doesn't not execute commands from shell with default keybinding for <Return>.
http://hg.python.org/cpython/rev/26b2407c644e
msg157068 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-29 16:55
New changeset 87ada87057a2 by Andrew Svetlov in branch '2.7':
Backport of Issue #14409 to 2.7
http://hg.python.org/cpython/rev/87ada87057a2
msg157069 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-03-29 16:58
Roger, now your solution is completely clean for me.

I pushed your patch to 2.7, 3.2 and 3.3 branches.

Thank you.
msg157094 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-03-29 20:24
(Thanks for the expanded analysis, Roger. I missed the implication of the title update you made.)
History
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58617
2012-03-29 20:24:43ned.deilysetmessages: + msg157094
2012-03-29 16:59:15asvetlovsetversions: + Python 3.2
2012-03-29 16:58:12asvetlovsetstatus: open -> closed
messages: + msg157069

assignee: asvetlov
resolution: fixed
stage: patch review -> resolved
2012-03-29 16:55:10python-devsetmessages: + msg157068
2012-03-29 16:01:51python-devsetnosy: + python-dev
messages: + msg157059
2012-03-29 14:59:04roger.serwysetmessages: + msg157054
2012-03-29 13:21:44asvetlovsetmessages: + msg157041
2012-03-29 03:14:00roger.serwysetmessages: + msg157009
2012-03-28 19:59:39ned.deilysetnosy: + ned.deily
messages: + msg157007
2012-03-28 19:10:40roger.serwysetfiles: + issue14409.patch


title: IDLE does not execute any commands (command prompt works fine!) -> IDLE: not executing commands from shell, error with default keybinding for Return
keywords: + patch
nosy: + asvetlov
versions: + Python 3.3
messages: + msg157000
stage: patch review
2012-03-28 18:16:45ankit615setfiles: + config-main.cfg

messages: + msg156995
2012-03-28 18:15:35ankit615setfiles: + config-extensions.cfg
status: pending -> open
messages: + msg156994
2012-03-26 23:08:43roger.serwysetstatus: open -> pending

messages: + msg156878
2012-03-26 22:55:02ankit615setstatus: pending -> open

messages: + msg156877
2012-03-26 20:03:17roger.serwysetstatus: open -> pending
2012-03-26 07:39:43roger.serwysetnosy: + roger.serwy
messages: + msg156800
2012-03-26 04:41:55ankit615create