classification
Title: IDLE shows traceback when printing non-BMP character
Type: behavior Stage: needs patch
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: belopolsky, irdb, terry.reedy
Priority: normal Keywords:

Created on 2014-10-27 16:18 by belopolsky, last changed 2017-06-19 19:06 by terry.reedy.

Messages (2)
msg230078 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2014-10-27 16:18
>>> print("\N{ROCKET}")
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    print("\N{ROCKET}")
  File "idlelib/PyShell.py", line 1352, in write
    return self.shell.write(s, self.tags)
UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001f680' in position 0: Non-BMP character not supported in Tk

Shouldn't IDLE replace non-encodable characters with "\uFFFD"?

I think

>>> "\N{ROCKET}"
�

is user-friendlier than the traceback.

See also #14304.
msg230416 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-11-01 00:36
I think Idle should consistently display astral chars with their \U escape.  It sometimes does, just not always.

>>> s='\U0001f680'
>>> s
'\U0001f680'
>>> str(s)
'\U0001f680'
>>> repr(s)
"'\U0001f680'"
>>> print(s) # gives error above.
>>> print(str(s))  #ditto

I thought that implicit print of expression and overt print of the same expression were supposed to be the same.

#21084 is also about this general issue.
History
Date User Action Args
2017-06-19 19:06:18terry.reedysetassignee: terry.reedy
components: + IDLE, - Library (Lib)
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2015-12-06 13:00:03irdbsetnosy: + irdb
2014-11-01 00:36:20terry.reedysetversions: + Python 2.7, Python 3.4, Python 3.5
nosy: + terry.reedy

messages: + msg230416

stage: needs patch
2014-10-27 16:18:24belopolskycreate