[ python-Bugs-1114093 ] inicode.decode

SourceForge.net noreply at sourceforge.net
Tue Feb 1 17:13:19 CET 2005


Bugs item #1114093, was opened at 2005-02-01 16:13
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1114093&group_id=5470

Category: Unicode
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Manlio Perillo (manlioperillo)
Assigned to: M.-A. Lemburg (lemburg)
Summary: inicode.decode

Initial Comment:
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32
bit (Intel)] on win32

>>> print sys.getdefaultencoding()
ascii


Regards.

The problem is this code:

# -*- coding: cp1252 -*-

>>> u'\xe0\xe8\xec\xf2\xf9'.decode('latin1')
Traceback (most recent call last):
  File "<pyshell#15>", line 1, in ?
    u'\xe0\xe8\xec\xf2\xf9'.decode('latin1')
UnicodeEncodeError: 'ascii' codec can't encode
characters in position 0-4: ordinal not in range(128)


I think this is a bug.
Indeed this is the behaviour of str.encode:

>>> '\xe0\xe8\xec\xf2\xf9'.encode('latin1')
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in ?
    '\xe0\xe8\xec\xf2\xf9'.encode('latin1')
UnicodeDecodeError: 'ascii' codec can't decode byte
0xe0 in position 0: ordinal not in range(128)

But this makes no sense for Unicode strings!
I think unicode.decode should be a no-op.



Manlio Perillo

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

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


More information about the Python-bugs-list mailing list