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 applies syntax highlighting to user input in its shell
Type: behavior Stage: test needed
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: peter.otten, terry.reedy
Priority: normal Keywords:

Created on 2013-11-27 08:42 by peter.otten, last changed 2022-04-11 14:57 by admin.

Messages (5)
msg204566 - (view) Author: Peter Otten (peter.otten) * Date: 2013-11-27 08:42
For example when you type

>>> input("What shall I do? ")
Run for your life!

in its shell window IDLE shows the 'for' as if it were a keyword. The same happens if you run a script that requires user interaction.
msg204772 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-11-30 04:12
I checked and Idle does not color code the prompt. In 2.7, it only color-codes the response to input(prompt), which is eval-ed as Python code, but not the response to raw_input(prompt). (In 2.7, the code and input displayed raises SyntaxError.) So the bug in 3.3 and 3.4 is that 3.3 input is being treated like 2.7 input rather than like 2.7 raw_input.

I suspect that we just need to find and delete the code that detects 'input()' and triggers highlighting.
msg204791 - (view) Author: Peter Otten (peter.otten) * Date: 2013-11-30 09:56
I think the prompt can easily be treated differently because it is written to stderr. 
I don't see a difference for user input between input() and raw_input() on Linux with Python 2.7.2+ -- syntax-highlighting is applied to both.
msg204840 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-11-30 19:29
On a freshly booted machine, I retried 2.7.6/Windows/raw_input() 'for all the' and indeed I now see 'for' and 'all' colored.

The colorizing is done char by char. 'fo' is black, 'for' turns orange, 'forr' turns black again. Similarly, 'al' is black, 'all is purple, and 'allo' is black again. It is not a critical bug, but certainly annoying, especially to a new user.

For editor windows, colorizing is only done for .py(wo) files. I do not know how the colorizing is switched on after the file name is checked. The shell window is an editor window. It should switch to .py mode after printing >>> and back to .txt mode when \n or \n\n is entered to complete a statement. I believe the edit will be in pyshell.py

I expect the prompt and echoed input are both written to stdout by the user process. Neither are errors and both are colored blue. Warnings and exception tracebacks on stderr are red. Both come into the idle process via the socket connection, which is different from the idle process stdin connected to the keyboard.
msg297338 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-30 01:02
Still a problem in 3.6.
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 64007
2017-06-30 01:02:08terry.reedysetassignee: terry.reedy
stage: test needed
messages: + msg297338
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.3, Python 3.4
2013-11-30 19:29:13terry.reedysetmessages: + msg204840
2013-11-30 12:30:48serhiy.storchakasetversions: + Python 2.7
2013-11-30 09:56:34peter.ottensetmessages: + msg204791
2013-11-30 04:12:50terry.reedysetversions: + Python 3.3, Python 3.4
nosy: + terry.reedy

messages: + msg204772

type: behavior
2013-11-27 08:46:26peter.ottensettitle: IDLE applys syntax highlighting to user input in its shell -> IDLE applies syntax highlighting to user input in its shell
2013-11-27 08:42:42peter.ottencreate