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

mario mario at ruggier.org
Wed Jan 2 03:24:59 EST 2008


Hello!

i stumbled on this situation, that is if I decode some string, below
just the empty string, using the mcbs encoding, it succeeds, but if I
try to encode it back with the same encoding it surprisingly fails
with a LookupError. This seems like something to be corrected?

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


Best wishes to everyone for 2008!

mario



More information about the Python-list mailing list