[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2010-08-07 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +merwok

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-04-04 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy:  -haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-04-03 Thread Ezio Melotti

Ezio Melotti  added the comment:

What I'm proposing is not to change the default error handler to
'backslashreplace', but just the behavior of sys.displayhook.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-04-01 Thread Atsuo Ishimoto

Atsuo Ishimoto  added the comment:

My proposal to make backslashreplace a default error handler 
for interactive session was rejected by Guido [1].

Does something like
  PYTHONIOENCODING=ascii:backslashreplace
work for you? With PYTHONIOENCODING, you can effectively make
backslashreplace a default error handler for your environment.


[1]: http://mail.python.org/pipermail/python-3000/2008-May/013928.html

--
nosy: +ishimoto

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-03-31 Thread Ezio Melotti

Ezio Melotti  added the comment:

In the first message I said that this breaks the PEP3138 because I
thought that the solution was to change the default error-handler to
'backslashreplace', but this was already proposed and refused.

sys.displayhook provides a way to change the behavior of the interactive
interpreter only when ">>> foo" is used. The PEP doesn't seem to say
anything about how ">>> foo" should behave.

Moreover, in the alternate solutions [1] they considered to use
sys.displayhook (and sys.excepthook) but they didn't because "these
hooks are called only when printing the result of evaluating an
expression entered in an interactive Python session, and doesn't work
for the print() function, for non-interactive sessions or for
logging.debug("%r", ...), etc."

This is exactly the behavior I intended to have, and, being a unique
feature of the interactive interpreter, it doesn't lead to inconsistence
with other situations.

[1]: http://www.python.org/dev/peps/pep-3138/#alternate-solutions

--
nosy: +atsuoi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-03-26 Thread STINNER Victor

STINNER Victor  added the comment:

martin> IIUC, this patch breaks PEP3138, 
martin> so it clearly must be rejected.

After reading the PEP3138, it's clear that this issue is not bug, and 
that we can not accept any patch fixing the issue without breaking the 
PEP.

Windows user who want to get the Python2 behaviour can use my display 
hook proposed in Message80823.

We can not fix this issue, so I choose to close it. If anyone wants to 
change the PEP, start a discussion on python-dev first.

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-02-12 Thread Ezio Melotti

Ezio Melotti  added the comment:

I've also noticed that if an error contains non-encodable characters,
they are escaped:
>>> raise ValueError("\u2620 can't be printed here, but '\u00e8' works
fine!")
Traceback (most recent call last):
  File "", line 1, in 
ValueError: \u2620 can't be printed here, but 'è' works fine!

but:
>>> "\u2620 can't be printed here, but '\u00e8' works fine!"
UnicodeEncodeError: 'charmap' codec can't encode character '\u2620' in
position 1: character maps to 

The mechanism used to escape errors is even better than my patch,
because it escapes only the chars that can't be encoded, instead of
escaping every non-ascii chars when at least one char can't be encoded:
>>> "\u2620 can't be printed here, but '\u00e8' works fine!"
"\u2620 can't be printed here, but '\xe8' works fine!"

I wonder if we can reuse the same mechanism here.

By the way, the patch I proposed in msg80852 is just a proof of concept,
if you think it's OK, someone will probably have to implement it in C.

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)

2009-02-03 Thread Ezio Melotti

Ezio Melotti  added the comment:

> Problem: use different (encoding) rule for the display hook and for
> print() may disturb new users (Why does ">>> chr(...)" work whereas
> ">>> print(chr(...))" fails?).

This is the same behavior that Python2.x has (with the only difference
that Py2 always show the char as u'\u' if >0x7F whereas Py3 /tries/
to display it):
>>> unichr(0x0100)
u'\u0100'
>>> print unichr(0x0100)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u0100' in
position 0: character maps to 

--
title: Printing Unicode chars from the interpreter in a non-UTF8 terminal (Py3) 
-> Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an 
error (Py3)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com