Repository navigation
Closed
Labels
Description
| BPO | 14304 |
|---|---|
| Nosy | @loewis, @terryjreedy, @abalkin, @pitrou, @ezio-melotti, @serwy, @asvetlov, @serhiy-storchaka |
| Files |
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:
assignee = 'https://github.com/asvetlov'
closed_at = <Date 2020-06-07.22:58:51.599>
created_at = <Date 2012-03-14.21:01:10.188>
labels = ['3.7', 'expert-IDLE', 'type-bug', 'expert-tkinter']
title = 'Implement utf-8-bmp codec'
updated_at = <Date 2020-06-07.23:13:21.632>
user = 'https://github.com/asvetlov'bugs.python.org fields:
activity = <Date 2020-06-07.23:13:21.632>
actor = 'vstinner'
assignee = 'asvetlov'
closed = True
closed_date = <Date 2020-06-07.22:58:51.599>
closer = 'terry.reedy'
components = ['IDLE', 'Tkinter']
creation = <Date 2012-03-14.21:01:10.188>
creator = 'asvetlov'
dependencies = []
files = ['25244']
hgrepos = []
issue_num = 14304
keywords = ['patch']
message_count = 30.0
messages = ['155793', '157235', '157248', '157263', '158372', '158424', '158426', '158460', '158467', '158470', '158486', '158487', '159497', '159530', '159531', '159538', '159541', '159543', '159544', '159545', '159546', '159547', '159582', '163745', '228168', '228175', '228182', '228183', '296687', '370920']
nosy_count = 9.0
nosy_names = ['loewis', 'terry.reedy', 'belopolsky', 'pitrou', 'ezio.melotti', 'roger.serwy', 'Arfrever', 'asvetlov', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue14304'
versions = ['Python 3.6', 'Python 3.7']
Activity
asvetlov commentedon Mar 14, 2012
Tkinter (and IDLE specially) can use only UCS-2 characters.
In PyShell IDLE tries to escape non-ascii.
To better result we should to escape only non-BMP chars leaving BMP characters untouched.
pitrou commentedon Mar 31, 2012
The solution outlined in the issue title ("utf-8-bmp codec") sounds like a rather dubious idea.
loewis commentedon Apr 1, 2012
pitrou: can you elaborate?
serhiy-storchaka commentedon Apr 1, 2012
''.join(c if ord(c) < 0x10000 else escape(c) for c in s)
vstinner commentedon Apr 15, 2012
What is this codec? What do you mean by "escpe non-ascii"?
loewis commentedon Apr 16, 2012
This codec is one that is equal to UTF-8, but restricted to the BMP. For non-BMP character, the error handler is called. It will be the stdout codec for the IDLE interactive shell, causing non-BMP results to be ascii() escaped.
asvetlov commentedon Apr 16, 2012
Tkinter (as Tcl itself) has no support of non-BMP characters in any form.
It looks like support of UTF-16 without surrogates.
I like to implement codec for that which will process different error modes (strict, replace, ignore etc) as well as others codecs does.
It will allow to support BMP well and control processing of non-BMP in IDLE.
About your second question.
IDLE has interactive shell. This shell in REPL will try to print expression result. It it contains non-BMP whole result is converted to ASCII with escaping. It's different from standard python console. From my perspective expected behavior is to pass BMP chars and escape only non-BMP.
serhiy-storchaka commentedon Apr 16, 2012
Example:
But I think that it is too specific problem and too specific solution. It would be better if IDLE itself escapes the string in the most appropriate way.
or
asvetlov commentedon Apr 16, 2012
The way is named 'codec'.
loewis commentedon Apr 16, 2012
That is not implementable correctly. If you think otherwise, please
submit a patch. If not, please trust me on that judgment.
serhiy-storchaka commentedon Apr 16, 2012
May be I did not correctly understand the problem, but I can assume,
that this patch solves it.
'Агов!\U00010000'
serhiy-storchaka commentedon Apr 16, 2012
Sorry, the mail daemon has eaten a piece of example.
>>> '\u0410\u0433\u043e\u0432!\U00010000' 'Агов!\U00010000'serhiy-storchaka commentedon Apr 27, 2012
Andrew, the patch solves your issue?
7 remaining items
serhiy-storchaka commentedon Apr 28, 2012
I don't understand how the utf-8-bmp codec will help to fix the tkinter. To fix the tkinter, you need to fix the Tcl/Tk, but it is outside of Python. While Tcl does not support non-bmp characters, correct and non-ambiguous working with non-bmp characters is not possible. You should choose the method of encoding of non-bmp characters and these methods will be different for different applications.
serhiy-storchaka commentedon Apr 28, 2012
If the application replaces the displayhook, than it is the development
environment too.
serhiy-storchaka commentedon Apr 29, 2012
Andrew, imagine that the utf-8-bmp codec is already there (I will do it
for you, if I see its necessity). How are you going to use it? Show a
patch that fixes IDLE and tkinter using this codec. It seems to me that
any result can be achieved without the codec, and not higher cost. And
that's not counting cost of the codec itself.
serhiy-storchaka commentedon Jun 24, 2012
Any chance to commit the patch before final feature freeze?
terryjreedy commentedon Oct 2, 2014
Pending doing some experiments with current and patched code, and reading the rpc code, I believe I would like to see the patch applied. I don't care about whether the patch defines a 'codec' or what its name would be. What i do want is for the Idle Shell to display unicode strings produced by python code as faithfully as possible, without raising an exception, given the limitations of tk and the selected font.
vstinner commentedon Oct 2, 2014
Is it always the case, or does depend on a compilation flag of Tcl or Tk?
serhiy-storchaka commentedon Oct 2, 2014
In theory Tcl/Tk can be built with 32-bit Tcl_Char. But I doubt that this option is well tested. In any case on Linux Python depends on system Tcl/Tk.
vstinner commentedon Oct 2, 2014
Would it make sense to compile Tcl/Tk with 32-bit Tcl_Char on Windows? I think that we embed our own build ot Tcl/Tk, right?
terryjreedy commentedon Jun 23, 2017
In 3.6, Python's use of the Windows console was changed to work much better with unicode. As a result, IDLE is now worse rather than better than the console on Windows. I plan to do something before 3.7.0.
terryjreedy commentedon Jun 7, 2020
Pasting astral characters into edited code 'works' except that editing following code is messy because the astral char is multiple chars internally and the visible cursor no longer matches the internal index. (But pasting such no longer crashes IDLE.)