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 crashes on opening invalid file
Type: crash Stage: resolved
Components: IDLE Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: amaury.forgeotdarc, ned.deily, python-dev, roger.serwy, royf
Priority: normal Keywords:

Created on 2010-05-23 09:41 by royf, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg106328 - (view) Author: (royf) Date: 2010-05-23 09:41
1. Create a file containing this line:
'\xdk'

2. Open the file for editing in IDLE 2.6.4. Banner:
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32

3. Run Module (F5) -> Bug#1: no error is shown

4. Run Module 7 more times (exactly!) -> Bug#2: IDLE crashes
msg106791 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-05-31 15:31
When running IDLE in a console, I get the error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "c:\prod\python\lib\lib-tk\Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "c:\prod\python\lib\idlelib\MultiCall.py", line 150, in handler
    r = l[i](event)
  File "c:\prod\python\lib\idlelib\ScriptBinding.py", line 140, in run_module_event
    code = self.checksyntax(filename)
  File "c:\prod\python\lib\idlelib\ScriptBinding.py", line 99, in checksyntax
    return compile(source, filename, "exec")
ValueError: invalid \x escape

The crash in "Bug#2" is certainly because pythonw.exe has no console, so sys.stdout blocks on the first flush(), after 4096 bytes of output.
msg147745 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2011-11-16 01:23
With IDLE 3.2 on Ubuntu 11.04, this is not a problem. An error box pops up:

SyntaxError
(unicode error) 'unicodeescape' codec can't decode bytes in position 0-3: truncated \xXX escape

With IDLE 2.7.1 on Ubuntu 11.04, the console gives the error described by Amaury.

A quick fix would be to add "ValueError" to the except clause in "checksyntax" in ScriptBinding for the 2.7 branch.
msg147746 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-16 02:30
New changeset e277fe8380e0 by Ned Deily in branch '2.7':
Issue #8793: Prevent IDLE crash in 2.7 when given strings with
http://hg.python.org/cpython/rev/e277fe8380e0
msg147747 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-11-16 02:33
Thank for the suggestion!  BTW, a similar change had been recently made to Python 3 for Issue9871 for invalid byte strings.
History
Date User Action Args
2022-04-11 14:57:01adminsetgithub: 53039
2011-11-16 02:33:41ned.deilysetstatus: open -> closed

assignee: ned.deily
versions: - Python 2.6
nosy: + ned.deily

messages: + msg147747
resolution: fixed
stage: resolved
2011-11-16 02:30:28python-devsetnosy: + python-dev
messages: + msg147746
2011-11-16 01:23:40roger.serwysetnosy: + roger.serwy

messages: + msg147745
versions: + Python 2.7
2010-05-31 15:31:07amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg106791
2010-05-23 09:41:58royfcreate