Serhiy Storchaka added the comment:
I'm going to commit my patch in few days. This is not perfect solution, but I
believe it is better than current state.
--
nosy: +benjamin.peterson
___
Python tracker rep...@bugs.python.org
Serhiy Storchaka added the comment:
Terry, what do you think? This bug is critical for non-ASCII-only users of IDLE.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
irdb added the comment:
Well, if there is no other way around this, I think it's better to apply
Martin's patch. At least then we will be able to enter any valid utf-8
character in IDLE (although print statement won't print correctly unless the
string is decoded first).
(As a Windows user,
Serhiy Storchaka added the comment:
Here is a patch with a hack which corrects a line number in displayed
traceback. It doesn't solve a problem totally, but perhaps it is a good enough
approximation.
--
Added file: http://bugs.python.org/file32671/idle_compile_coding_3.patch
Changes by Serhiy Storchaka storch...@gmail.com:
--
stage: needs patch - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
irdb added the comment:
Thank you Serhiy for working on this. This patch solves the problem when all
your input characters are encodable using system preferred encoding. But
issue19625 persists. I still can't print something like 'Русский текст' in
interactive mode.
Another problem is that
Geraldo Xexeo added the comment:
The same program will behave different in Windows and Mac.
utf-8 works on Mac (10.6.8), cp1256 does not print some lines
cp1256 works on Windows 7, utf-8 prints some characters in a wrong way
For the record, I use accentuated letters from Portuguese alphabet (
Serhiy Storchaka added the comment:
Use cp1256 encoding in your source file. It is expected that usually your
source files encoding is same as your locale encoding. In such case printing
string literals and Unicode string literals produces same result (as they look
in the sources).
s1 is
irdb added the comment:
Sorry, it's probably has the same problem as what Martin suggested. Although I
think it's better than having program interrupted.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
Serhiy Storchaka added the comment:
How about passing on UnicodeError?
I don't see how it will resolve any problem.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
irdb added the comment:
Oops! My problem is that I get Unsupported characters in input when trying to
type any Unicode string in IDLE's interactive mode.
e.g. a simple command like: s = u'Русский текст' gives: Unsupported characters
in input
Probably unrelated to the issue at hand. I don't
irdb added the comment:
I really think this information might help, if not, I promise not to post
anything else. :)
This is a sample program I run:
'''
# -*- coding: utf-8 -*-
import sys
import locale
de = sys.getdefaultencoding()
pd = locale.getpreferredencoding()
print de, pd
s1 = 'سلام'
Changes by ali mr.da...@gmail.com:
--
nosy: +irdb
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
Python-bugs-list mailing list
Serhiy Storchaka added the comment:
Good catch. Thank you, Roger.
--
stage: patch review - needs patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
Serhiy Storchaka added the comment:
If there are no objections I will commit the patch soon.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
Roger Serwy added the comment:
There is a problem. Adding the encoding comment to the top of the source causes
off-by-one line errors in the traceback.
Take as an example:
1/0
Traceback (most recent call last):
File pyshell#0, line 2, in module
ZeroDivisionError: integer division or
Serhiy Storchaka added the comment:
Here's a tangentially related issue: #14326
Yes, this issue looks as a prerequisite for it.
IDLE doesn't handle pasting multi-line code properly (issue3559), IDLE2 will
silently ignore code after the first executable statement. IDLE3 may give an
error.
Serhiy Storchaka added the comment:
The problem (as I understand it) is that if Martin's patch fixes an unicode
literals, it breaks a string literals.
LC_ALL=ru_RU.cp1251 LANG=ru_RU.cp1251 ./python Lib/idlelib/idle.py
print u'йцук'
йцук
print 'йцук'
йцук
Here is a different patch,
R. David Murray added the comment:
I've combined the nosy lists and will close the other issue. Serhiy, what if
the source already has a coding cookie line?
--
nosy: +Pradyun.Gedam, Tomoki.Imai, ned.deily, r.david.murray
___
Python tracker
Serhiy Storchaka added the comment:
A coding cookie line will be ignored. Note that this affects only very obscure
case when you are pasting a multiline code with a coding cookie line into IDLE
shell (this is only way to get a coding cookie line in the shell). Running a
file does not pass
Serhiy Storchaka added the comment:
An interactive Python console ignores a coding cookie line too.
$ cat test.py
# -*- coding: koi8-r -*-
print repr('йцук'), 'йцук', repr(u'йцук'), u'йцук'
$ LC_ALL=ru_RU.cp1251 LANG=ru_RU.cp1251 ./python test.py
'\xe9\xf6\xf3\xea' йцук
Roger Serwy added the comment:
Here's a tangentially related issue: #14326
IDLE doesn't handle pasting multi-line code properly (issue3559), IDLE2 will
silently ignore code after the first executable statement. IDLE3 may give an
error.
Can't we just make IDLE's shell default to UTF-8?
Changes by Serhiy Storchaka storch...@gmail.com:
--
assignee: - serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
Serhiy Storchaka added the comment:
However, this patch isn't right, since it will cause all source to be
interpreted as UTF-8. This would be wrong when the sys.stdin.encoding is not
UTF-8, and byte string objects are created in interactive mode.
Can you show how to reproduce the error
Changes by Serhiy Storchaka storch...@gmail.com:
--
stage: - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
Changes by Terry J. Reedy tjre...@udel.edu:
--
nosy: +terry.reedy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
Python-bugs-list
Changes by Andrew Svetlov andrew.svet...@gmail.com:
--
title: Строки из IDLE поступают в неверной кодировке. - IDLE console uses
incorrect encoding.
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
alex hartwig added the comment:
Text is correct. See attachment.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15809
___
___
Python-bugs-list
Martin v. Löwis added the comment:
The problem is that IDLE passes an UTF-8 encoded source string to compile, and
compile, in the absence of a source encoding, uses the PEP 263 default source
encoding, i.e. Latin-1.
As the consequence, the variable s has the value
29 matches
Mail list logo