New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE crashes when printing some unprintable characters. #57474
Comments
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 []). |
Here's the Error message. Object: stdout Traceback (most recent call last):
File "/usr/lib/python3.2/idlelib/rpc.py", line 188, in localcall
ret = method(*args, **kwargs)
File "/usr/lib/python3.2/idlelib/PyShell.py", line 1220, in write
self.shell.write(s, self.tags)
File "/usr/lib/python3.2/idlelib/PyShell.py", line 1202, in write
OutputWindow.write(self, s, tags, "iomark")
File "/usr/lib/python3.2/idlelib/OutputWindow.py", line 40, in write
self.text.insert(mark, s, tags)
File "/usr/lib/python3.2/idlelib/Percolator.py", line 25, in insert
self.top.insert(index, chars, tags)
File "/usr/lib/python3.2/idlelib/ColorDelegator.py", line 79, in insert
self.delegate.insert(index, chars, tags)
File "/usr/lib/python3.2/idlelib/PyShell.py", line 312, in insert
UndoDelegator.insert(self, index, chars, tags)
File "/usr/lib/python3.2/idlelib/UndoDelegator.py", line 81, in insert
self.addcmd(InsertCommand(index, chars, tags))
File "/usr/lib/python3.2/idlelib/UndoDelegator.py", line 116, in addcmd
cmd.do(self.delegate)
File "/usr/lib/python3.2/idlelib/UndoDelegator.py", line 219, in do
text.insert(self.index1, self.chars, self.tags)
File "/usr/lib/python3.2/idlelib/ColorDelegator.py", line 79, in insert
self.delegate.insert(index, chars, tags)
File "/usr/lib/python3.2/idlelib/WidgetRedirector.py", line 104, in __call__
return self.tk_call(self.orig_and_operation + args)
ValueError: unsupported character |
My OS is Ubuntu Linux 11.10 (Oneiric Ocelot) |
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? |
The error is visible from the command-line. |
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. |
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? |
Sorry, I should have noticed earlier that this is a duplicate of bpo-12342. 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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: