Harri Pasanen: Re: [Idle-dev] Known bug? Saving fails in IDLE if accents used in char acters
Martin von Loewis
loewis@informatik.hu-berlin.de
Mon, 24 Mar 2003 15:05:42 +0100 (CET)
> > There is not much we can do about this; IDLE *could* try to edit
> > the file for you, but I consider this too intrusive, hence the
> > error message.
> >
>
> My vote for IDLE inserting the font encoding line to top of file if it
> does not exist.
I'm implementing a change into that direction right now: The dialog
will have a button "Edit my text", which does the appropriate editing.
> Note that the message box is also in a proportional, not fixed font,
> so spotting the spaces is not obvious.
I see. I'll try to make this a fixed font, as well.
> But the PEP states:
>
> 1. Allow non-ASCII in string literals and comments, by internally
> treating a missing encoding declaration as a declaration of
> "iso-8859-1".
>
> The current IDLE or IDLEfork does not seem to do above.
Strictly speaking, this is how Python will *interpret* a file with
no encoding declaration; this specific interpretation must be chosen
for backwards compatibility with 2.2 (which treats non-ASCII bytes
in Unicode literals as Latin-1, which is a flaw that triggered
PEP 263).
IDLE itself needs different backwards compatibility: People do use
non-ASCII non-Latin-1 in Python source code, so IDLE treats
"no encoding declaration" as "encoded in the locale's encoding".
For the majority of existing code, this is the right approach.
Notice that IDLE *does* allow you to use Latin-1 in source code
without explicit declaration. Once you press "OK", IDLE will safe
the file in the locale's encoding (which is probably Latin-1
or CP 1252 for you). The message box is just a warning, created
every time you safe the file - but it will still be safed, and
loaded.
> And what
> about maintaining legacy python code with IDLE, much of which is in
> is-8859-1 I suppose?
This assumption is incorrect. Kirill Simonov was the first to complain
about IDLE not supporting "funny" characters, and he is using Cyrillic
in all his files. He would be quite unhappy if IDLE started displaying
mojibake to him.
> Starting from 2.3 I understand?
Correct.
Martin