Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82515

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

Newsgroups comp.lang.python
Date 2014-12-14 09:21 -0800
References <mailman.16902.1418376062.18130.python-list@python.org>
Message-ID <6ed57daf-29ec-4b45-b8b6-233d8d14cc02@googlegroups.com> (permalink)
Subject Re: encoding name mappings in codecs.py with email/charset.py
From gst <g.starck@gmail.com>

Show all headers | View raw


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.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

encoding name mappings in codecs.py with email/charset.py Stefanos Karasavvidis <sk@isc.tuc.gr> - 2014-12-12 11:05 +0200
  Re: encoding name mappings in codecs.py with email/charset.py gst <g.starck@gmail.com> - 2014-12-14 09:21 -0800
    Re: encoding name mappings in codecs.py with email/charset.py Stefanos Karasavvidis <sk@isc.tuc.gr> - 2014-12-14 21:09 +0200
      Re: encoding name mappings in codecs.py with email/charset.py gst <g.starck@gmail.com> - 2014-12-14 11:53 -0800
        Re: encoding name mappings in codecs.py with email/charset.py Stefanos Karasavvidis <sk@isc.tuc.gr> - 2014-12-15 13:27 +0200

csiph-web