Bugs item #1099364, was opened at 2005-01-10 11:33
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1099364&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 6
Submitted By: Petr Prikryl (prikryl)
Assigned to: Nobody/Anonymous (nobody)
Summary: raw_input() displays wrong unicode prompt

Initial Comment:
I have observed a problem when running 
Python 2.4, Windows version (python-2.4.msi)
and using raw_input() with unicode prompt
string in a console program (ran in the DOS window).

I do use the following sitecustomize.py file to set
the default encoding in the English Windows 2000 Server:

sitecustomize.py
=================================
import sys
sys.setdefaultencoding('cp1250')
=================================


test.py
=================================
# -*- coding: cp1250 -*-
s = u'string with accented letters (different than this)'
print s                    # OK
val = raw_input(s)    # s displayed differently (wrong)
=================================

See the test.png
(captured from screen) and the test.py for the
used string -- inside the attached zip file. 

The "type test.py" (result visible on the captured
screen) displays the string
definition also wrongly, because the DOS window
uses different encoding than cp1250. The print
command prints the string correctly, converting
the internal unicode string to the encoding that
the is defined by the output environment. However,
the raw_input() probably does convert the unicode
string to the cp1250 and does not do the same
(more clever) thing that the print does.

I did not use the unicode in older Python (2.3.4),
so I do not know what was the behaviour earlier.

Could you confirm the bug? Sorry if the bug
is well known.

Petr


----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-26 22:34

Message:
Logged In: YES 
user_id=1188172

Actually, your sys.stdout.encoding is set to something
different than cp1250, which is why the result of DOS type
looks the same as the one of print.

This is because print observes sys.stdout.encoding, while
sys.stdout.write uses the system default encoding, which is,
as you set it, cp1250 and is displayed wrong on the console.

Closing this bug, as it is currently expected behaviour (but
will perhaps change when patch #1214889 is accepted).

----------------------------------------------------------------------

Comment By: Petr Prikryl (prikryl)
Date: 2005-04-14 16:34

Message:
Logged In: YES 
user_id=771873

Python 2.4.1 for Windows behaves the same way.

Petr

----------------------------------------------------------------------

Comment By: Petr Prikryl (prikryl)
Date: 2005-04-14 16:26

Message:
Logged In: YES 
user_id=771873

New observation: sys.stdout.write(s) behaves visually on the 
screen exactly as the raw_input(s) does. So, print does 
something more when displaying on the screen...

Petr

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1099364&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to