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: Undesired behavior of emoji in editor.
Type: behavior Stage:
Components: IDLE Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Alex-Python-Programmer, terry.reedy
Priority: normal Keywords:

Created on 2020-03-29 08:29 by Alex-Python-Programmer, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg365247 - (view) Author: Alex (Alex-Python-Programmer) Date: 2020-03-29 08:29
Python 3.8.2 IDLE has an unexpected behavior.
When I insert an emoji into IDLE like '😍'.
Then I found I can't delete it(by typing backspace).
When I type the left arrow then it became 'νΈνΈ'(U+FFFD).
Then I type the left arrow again, then it is '😍' again!
(When I use the delete button, or type the right button there aren't any bugs.)
What's wrong?
Also, when I have two emojis like 'πŸ™πŸ™', I press delete button between them, nothing happens; when I delete on the right, both of them disappear!
(This bug seems not appears on plain 0.)
msg365250 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-29 11:02
Terminal codepages are irrelevant in the IDLE tk based gui.  The problem is that windows codes astral chars as two surrogates.  While tkinter can display them, after recent changes to _tkinter, the text widget cannot handle then properly when editing.  This was explained in more detail on an earlier issue, but I will have to check if there is already an issue for fixing it.

For editing, one should use unicode escapes, as in

>>> print('\U0001f60d')

Python in a Windows console prints the surrogates separately.

and in IDLE, one will see a black-and_white version of the smiley.
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84281
2020-03-29 11:02:24terry.reedysetmessages: + msg365250
title: Unexpected behavior when handling emoji under codec cp936 -> IDLE: Undesired behavior of emoji in editor.
2020-03-29 08:29:07Alex-Python-Programmercreate