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


Groups > comp.lang.python > #82523

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <sk@isc.tuc.gr>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'encoding': 0.05; 'class,': 0.07; 'aliases': 0.09; 'mailman': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'skip:= 70': 0.12; 'campus,': 0.16; 'charset': 0.16; 'cleaner': 0.16; 'dict': 0.16; 'm.sc.': 0.16; '\xc3\xa9crit\xc2\xa0:': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'solution.': 0.20; 'seems': 0.21; '>>>': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; '&gt;&gt;&gt;': 0.24; 'skip:e 30': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; '&gt;': 0.26; 'subject:/': 0.26; 'somewhere': 0.26; 'header:In- Reply-To:1': 0.27; 'character': 0.29; 'patch': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'names.': 0.31; 'url:python': 0.33; 'received:74.125.82': 0.34; 'could': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'building': 0.35; '14,': 0.36; 'url:listinfo': 0.36; 'method': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'received:74.125': 0.39; 'university': 0.39; 'url:mail': 0.40; 'e-mail:': 0.61; 'simply': 0.61; 'more': 0.64; 'tel.:': 0.65; 'wall': 0.65; 'to:addr:gmail.com': 0.65; 'mar': 0.68; 'caused': 0.69; '2014,': 0.84; 'dict.': 0.84
X-Gm-Message-State ALoCoQnOzuzP9pKQf2/VqFZH+QizdafXzYbSRAHWsHr3X/N2ielcKeHn5NvB3lrqeDjn32GgCoYL
X-Received by 10.180.186.40 with SMTP id fh8mr25735259wic.40.1418584199013; Sun, 14 Dec 2014 11:09:59 -0800 (PST)
MIME-Version 1.0
In-Reply-To <6ed57daf-29ec-4b45-b8b6-233d8d14cc02@googlegroups.com>
References <mailman.16902.1418376062.18130.python-list@python.org> <6ed57daf-29ec-4b45-b8b6-233d8d14cc02@googlegroups.com>
From Stefanos Karasavvidis <sk@isc.tuc.gr>
Date Sun, 14 Dec 2014 21:09:38 +0200
Subject Re: encoding name mappings in codecs.py with email/charset.py
To gst <g.starck@gmail.com>
Content-Type multipart/alternative; boundary="001a11c2681c444288050a31dfcc"
X-Originating-IP [74.125.82.48]
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16953.1418584209.18130.python-list@python.org> (permalink)
Lines 158
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418584209 news.xs4all.nl 2854 [2001:888:2000:d::a6]:58732
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82523

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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@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@isc.tuc.gr>e-mail: sk@isc.tuc.gr, Tel.: (+30) 2821037508, Fax: (+30)
2821037520
Technical University of Crete, Campus, Building A1

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