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 crashes when printing some unprintable characters.
Type: Stage: resolved
Components: IDLE Versions: Python 3.2
Status: closed Resolution: duplicate
Dependencies: Superseder: characters with ord above 65535 fail to display in IDLE
View: 12342
Assigned To: Nosy List: Ramchandra Apte, ezio.melotti, kbk, ned.deily, roger.serwy
Priority: normal Keywords: patch

Created on 2011-10-26 05:48 by Ramchandra Apte, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
patch13265.diff roger.serwy, 2011-10-30 18:43
Messages (8)
msg146411 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-10-26 05:48
When you print an unprintable character, IDLE raises an error.
>>> print(chr(500304)) # print an unprintable character
The error is only visible when you run the code from a commmand-line.
When you run python from the command-line and execute the code it shows
the unprintable character symbol (looks like []).
msg146412 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-10-26 05:51
Here's the Error message.
*** Internal Error:

 Object: stdout 
 Method: <bound method PseudoFile.write of <idlelib.PyShell.PseudoFile object at 0x2675550>> 
 Args: ('\U0007a250',)

Traceback (most recent call last):
  File "/usr/lib/python3.2/idlelib/", line 188, in localcall
    ret = method(*args, **kwargs)
  File "/usr/lib/python3.2/idlelib/", line 1220, in write, self.tags)
  File "/usr/lib/python3.2/idlelib/", line 1202, in write
    OutputWindow.write(self, s, tags, "iomark")
  File "/usr/lib/python3.2/idlelib/", line 40, in write
    self.text.insert(mark, s, tags)
  File "/usr/lib/python3.2/idlelib/", line 25, in insert, chars, tags)
  File "/usr/lib/python3.2/idlelib/", line 79, in insert
    self.delegate.insert(index, chars, tags)
  File "/usr/lib/python3.2/idlelib/", line 312, in insert
    UndoDelegator.insert(self, index, chars, tags)
  File "/usr/lib/python3.2/idlelib/", line 81, in insert
    self.addcmd(InsertCommand(index, chars, tags))
  File "/usr/lib/python3.2/idlelib/", line 116, in addcmd
  File "/usr/lib/python3.2/idlelib/", line 219, in do
    text.insert(self.index1, self.chars, self.tags)
  File "/usr/lib/python3.2/idlelib/", line 79, in insert
    self.delegate.insert(index, chars, tags)
  File "/usr/lib/python3.2/idlelib/", line 104, in __call__
    return self.tk_call(self.orig_and_operation + args)
ValueError: unsupported character
msg146413 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-10-26 05:56
My OS is Ubuntu Linux 11.10 (Oneiric Ocelot)
Running uname -a gives "Linux ramcomputer 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux"
msg146414 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-26 05:57
Both print(chr(500304)) and print('\U0007a250') seem to work and print two empty boxes on IDLE with Python 3.2/WinXP.

Is that error displayed in the IDLE window or does IDLE crash and you see the error somewhere else?
msg146415 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-10-26 05:59
The error is visible from the command-line.
msg146448 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-10-26 18:15
With a current 3.3 build (i.e. "wide" build) on OS X, I can reproduce this. It causes an exception on the execution of that command in the IDLE shell but it doesn't crash IDLE.  Not surprisingly, it doesn't seem to be reproducible with 3.2 "narrow" builds.
msg146652 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2011-10-30 18:43
I can reproduce the problem with Ubuntu 11.04 with Python 3.2. The WidgetRedirector calls tk_call with a tuple containing unencoded Unicode strings. 

Attached is a patch to encode all arguments if the argument has the "encode" attribute. This seems to fix the problem, but can someone who knows more about Python and Tk's Unicode handling take a look?
msg146662 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-10-30 21:45
Sorry, I should have noticed earlier that this is a duplicate of Issue12342.  The problem is simply that Tcl/Tk does not currently support the display of Unicode code points outside of the BMP.  The question then is what IDLE to do when asked to display such characters.  The current behavior of letting tkinter detect the unsupported code point and bubbling up a somewhat unhelpful exception message is not the most user-friendly response.  Let's continue any discussion of this over on the earlier issue.
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57474
2011-10-30 21:45:57ned.deilysetstatus: open -> closed
resolution: duplicate
messages: + msg146662

superseder: characters with ord above 65535 fail to display in IDLE
stage: resolved
2011-10-30 18:43:11roger.serwysetfiles: + patch13265.diff

nosy: + roger.serwy
messages: + msg146652

keywords: + patch
2011-10-29 11:17:38Ramchandra Aptesetversions: - Python 3.3
2011-10-26 18:15:12ned.deilysetversions: + Python 3.3
nosy: + ned.deily

messages: + msg146448

type: crash ->
2011-10-26 05:59:36Ramchandra Aptesetmessages: + msg146415
2011-10-26 05:57:31ezio.melottisetnosy: + kbk, ezio.melotti
messages: + msg146414
2011-10-26 05:56:03Ramchandra Aptesetmessages: + msg146413
2011-10-26 05:51:33Ramchandra Aptesetmessages: + msg146412
2011-10-26 05:48:48Ramchandra Aptecreate