[ python-Bugs-773351 ] Dubious use of Unicode literals in tutorial

SourceForge.net noreply at sourceforge.net
Mon Aug 9 22:19:25 CEST 2004


Bugs item #773351, was opened at 2003-07-18 02:10
Message generated for change (Comment added) made by ghaering
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=773351&group_id=5470

Category: Documentation
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Gerhard Häring (ghaering)
Assigned to: Gerhard Häring (ghaering)
Summary: Dubious use of Unicode literals in tutorial

Initial Comment:
"3.1.3 Unicode Strings" contains:

>>> u"äöü"
u'\xe4\xf6\xfc'

It looks like latin1 is used as encoding for this
Unicode literal. This is, however, neither justified by
the Python language specification nor by common sense ;-)

I'd suggest that this be changed in the tutorial.

Furthermore I'd suggest that such use of Unicode
literals throw errors instead.

I'm assigning it to Martin, because he's one of the
Unicode gurus :)

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

>Comment By: Gerhard Häring (ghaering)
Date: 2004-08-09 22:19

Message:
Logged In: YES 
user_id=163326

I just read PEP 0263, which says:

"""
In Python 2.1, Unicode literals can only be written using the
Latin-1 based encoding "unicode-escape".
"""

So the tutorial is correct and the things Martin suggested
are only possible improvements to Python, there's no actual
bug here.

So I'll close this one.

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

Comment By: Martin v. Löwis (loewis)
Date: 2003-07-18 17:04

Message:
Logged In: YES 
user_id=21627

The intended behaviour is that Unicode in the interactive
mode "works", and assumes that the actual input is encoded
according to the locale's encoding (i.e.
sys.stdin.encoding). That isn't implemented, yet (and
perhaps not even specified). However, it is most likely the
case that this is a doc bug in ref manual, not in the tutorial.

For this to work, the interactive mode needs to be able to
pass the encoding to the parser, perhaps giving a Unicode
object as the argument instead of a byte string (atleast
IDLE might want to do that). Passing Unicode objects to
eval/exec is for further study, though.

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

Comment By: Gerhard Häring (ghaering)
Date: 2003-07-18 11:55

Message:
Logged In: YES 
user_id=163326

Oh, I almost forgot about my original problem. Such
behaviour shouldn't be encouraged in the tutorial any longer
of course. Maybe I can find a better wording and submit a
patch soonish. Now that I understand this better, assignnig
this to myself :)

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

Comment By: Gerhard Häring (ghaering)
Date: 2003-07-18 11:54

Message:
Logged In: YES 
user_id=163326

I *do* get the warnings when executing scripts, but I do
*not* get the warnings at the interactive prompt. Lowering
priority accordingly. Feel free to close this if this is
indeed the intended behaviour.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=773351&group_id=5470


More information about the Python-bugs-list mailing list