encoding name mappings in codecs.py with email/charset.py

Stefanos Karasavvidis sk at isc.tuc.gr
Sun Dec 14 14:09:38 EST 2014


thanks for replying gst.

I've thought already of patching the Charset class, but hoped for a cleaner
solution.

This ALIASES dict has already all the iso names *with* a dash. So it must
get striped somewhere else.

sk

On Sun, Dec 14, 2014 at 7:21 PM, gst <g.starck at gmail.com> wrote:

> Le vendredi 12 décembre 2014 04:21:14 UTC-5, Stefanos Karasavvidis a
> écrit :
> > I've hit a wall with mailman which seems to be caused by pyhon's
> character encoding names.
> >
> > I've narrowed the problem down to the email/charset.py file. Basically
> the following happens:
> >
>
> Hi,
>
> it's all in the email.charset.ALIASES dict.
>
> you could also simply patch the __str__ method of Charset :
>
> Python 2.7.6 (default, Mar 22 2014, 22:59:56)
> [GCC 4.8.2] on linux2
> Type "copyright", "credits" or "license()" for more information.
> >>>
> >>> import email.charset
> >>>
> >>> c = email.charset.Charset('iso-8859-7')
> >>> str(c)
> 'iso8859-7'
> >>>
> >>> old = email.charset.Charset.__str__
> >>>
> >>> def patched(self):
>         r = old(self)
>         if r.startswith('iso'):
>                 return 'iso-' + r[3:]
>         return r
>
> >>>
> >>> email.charset.Charset.__str__ = patched
> >>>
> >>> str(c)
> 'iso-8859-7'
> >>>
>
>
> regards,
>
> gst.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
======================================================================
Stefanos Karasavvidis,  Electronic & Computer Engineer, M.Sc.
<sk at isc.tuc.gr>e-mail: sk at isc.tuc.gr, Tel.: (+30) 2821037508, Fax: (+30)
2821037520
Technical University of Crete, Campus, Building A1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141214/80c77d14/attachment.html>


More information about the Python-list mailing list