different encodings for unicode() and u''.encode(), bug?

Piet van Oostrum piet at cs.uu.nl
Wed Jan 2 08:25:48 EST 2008


>>>>> mario <mario at ruggier.org> (M) wrote:

>M> $ python
>M> Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
>M> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
>M> Type "help", "copyright", "credits" or "license" for more information.
>>>>> unicode('', 'mbcs')
>M> u''
>>>>> unicode('abc', 'mbcs')
>M> Traceback (most recent call last):
>M>   File "<stdin>", line 1, in <module>
>M> LookupError: unknown encoding: mbcs
>>>>> 

>M> Hmmn, strange. Same behaviour for "raboof".

Apparently for the empty string the encoding is irrelevant as it will not
be used. I guess there is an early check for this special case in the code.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list