Pavel Kosina g...@post.cz added the comment:
I vote for fixing this too. This might be simplified/another example of
above mentioned issues:
# -*- coding: utf-8 -*-
print (ěščřžýáíé)
in IDLE prints this:
ěščřžýáĂĂ©
When running this script under python command line from another
Martin v. Löwis mar...@v.loewis.de added the comment:
Here is a new patch that fixes this issue, and the duplicate issues
(#4410, and #4623).
It doesn't try to eliminate code duplication, but fixes coding_spec by
decoding always to Latin-1 first until the coding is known. It fixes
check_syntax
Terry J. Reedy [EMAIL PROTECTED] added the comment:
This is still a problem on my WinXP 3.0rc3 with
# -*- coding: utf-8 -*-
in a file but not with the same pasted directly into the shell Window.
--
nosy: +tjreedy
type: - crash
___
Python tracker
Martin v. Löwis [EMAIL PROTECTED] added the comment:
This patch has two problems:
1. saving files fails, since there is still a call left to the function
coding_spec, but that function is removed.
2. if saving would work: it doesn't preserve the line endings of the
original file when writing it
Changes by STINNER Victor [EMAIL PROTECTED]:
Removed file: http://bugs.python.org/file11677/idle_encoding-2.patch
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4008
___
Martin v. Löwis [EMAIL PROTECTED] added the comment:
@loewis: I guess that your locale is still UTF-8.
To refute this claim, I reported that locale.getpreferredencoding
reports 'ANSI_X3.4-1968'. I was following your instructions exactly
(on Debian 4.0), and still, it opens successfully (when
STINNER Victor [EMAIL PROTECTED] added the comment:
@loewis: I guess that your locale is still UTF-8.
On Linux (Ubuntu Gutsy) using env -i DISPLAY=$DISPLAY HOME=$HOME
xterm to get a new empty environment, I get:
$ locale
LANG=
LC_ALL=
LC_CTYPE=POSIX
LC_NUMERIC=POSIX
LC_TIME=POSIX
Changes by STINNER Victor [EMAIL PROTECTED]:
Removed file: http://bugs.python.org/file11673/idle_encoding.patch
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4008
___
STINNER Victor [EMAIL PROTECTED] added the comment:
Ah! tokenize has already a method detect_encoding(). My new patch uses
it to avoid code duplication.
Added file: http://bugs.python.org/file11677/idle_encoding-2.patch
___
Python tracker [EMAIL PROTECTED]
Martin v. Löwis [EMAIL PROTECTED] added the comment:
Notice that there is also IOBinding.coding_spec. Not sure whether this
or the one in tokenize is more correct.
--
nosy: +loewis
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4008
STINNER Victor [EMAIL PROTECTED] added the comment:
loewis wrote:
Notice that there is also IOBinding.coding_spec.
Not sure whether this or the one in tokenize is more correct.
Oh! IOBinding reimplement many features now available in Python like
universal new line or function to write
Martin v. Löwis [EMAIL PROTECTED] added the comment:
Oh! IOBinding reimplement many features now available in Python like
universal new line or function to write unicode strings to a file.
It did not *re*implement. The implementation in IOBinding predates all
other implementations out there.
STINNER Victor [EMAIL PROTECTED] added the comment:
@loewis: Ok, I didn't know. I think that it's better to reuse existing
code.
I also compared the implementations of encoding detection, and the
code looks the same in IDLE and tokenize, but I prefer tokenize.
tokenize.detect_encoding() has
Martin v. Löwis [EMAIL PROTECTED] added the comment:
I can't reproduce the problem. It works fine for me, displaying the box
drawing character. In case it matters, sys.getpreferredencoding returns
'ANSI_X3.4-1968'; this is on Linux, idle started from an xterm, r66761
14 matches
Mail list logo