Author xnovakj
Recipients barry, xnovakj
Date 2009-03-23.10:12:24
SpamBayes Score 0.000252309
Marked as misclassified No
Message-id <1237803146.27.0.212514283495.issue1379416@psf.upfronthosting.co.za>
In-reply-to
Content
I made some new tests in P2.6.1

>>> import email.charset

>>> c=email.charset.Charset('utf-8')
>>> print c.input_charset, type(c.input_charset)
utf-8 <type 'unicode'>
>>> print c.output_charset, type(c.output_charset)
utf-8 <type 'str'>

but

>>> c=email.charset.Charset('iso-8859-2')
>>> print c.input_charset, type(c.input_charset)
iso-8859-2 <type 'unicode'>
>>> print c.output_charset, type(c.output_charset)
iso-8859-2 <type 'unicode'>

but if you use alias latin-2 it's OK

>>> c=email.charset.Charset('latin-2')
>>> print c.input_charset, type(c.input_charset)
iso-8859-2 <type 'str'>
>>> print c.output_charset, type(c.output_charset)
iso-8859-2 <type 'str'>
>>> 

Error is here for unicode input-charset:
self.input_charset->conv->self.output_charset

module email/charset.py line 219

        if not conv:
            conv = self.input_charset

for the charsets where aren't output conversions

CHARSETS = {
    # input        header enc  body enc output conv
    'iso-8859-1':  (QP,        QP,      None),
    'iso-8859-2':  (QP,        QP,      None),

and if you don't use alias

ALIASES = {
    'latin_1': 'iso-8859-1',
    'latin-1': 'iso-8859-1',
    'latin_2': 'iso-8859-2',
    'latin-2': 'iso-8859-2',

But the realy source of this error is on line 208
 input_charset = unicode(input_charset, 'ascii')

because this construction returns unicode

>>> print type(unicode('iso-8859-2','ascii'))
<type 'unicode'>
History
Date User Action Args
2009-03-23 10:12:26xnovakjsetrecipients: + xnovakj, barry
2009-03-23 10:12:26xnovakjsetmessageid: <1237803146.27.0.212514283495.issue1379416@psf.upfronthosting.co.za>
2009-03-23 10:12:25xnovakjlinkissue1379416 messages
2009-03-23 10:12:24xnovakjcreate