Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.045 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'mailman.': 0.03; 'encoding': 0.05; 'mailman': 0.10; 'python': 0.11; 'skip:= 70': 0.12; '(without': 0.16; 'campus,': 0.16; 'charset': 0.16; 'codecs': 0.16; 'm.sc.': 0.16; 'basically': 0.19; 'file,': 0.19; 'seems': 0.21; 'example': 0.22; 'import': 0.22; 'file.': 0.24; 'environment': 0.24; 'question': 0.24; "i've": 0.25; 'subject:/': 0.26; 'tried': 0.27; 'character': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'names.': 0.31; 'python2.7': 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'received:209.85.212': 0.32; 'problem': 0.35; 'subject:with': 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'building': 0.35; 'there': 0.35; 'ubuntu': 0.36; 'done': 0.36; 'received:209': 0.37; 'mapping': 0.38; 'to:addr:python- list': 0.38; 'issue': 0.38; "couldn't": 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'university': 0.39; 'e-mail:': 0.61; 'first': 0.61; 'exchange': 0.63; 'name': 0.63; 'tel.:': 0.65; 'wall': 0.65; 'caused': 0.69; '\xc2\xa0\xc2\xa0': 0.74; '100%': 0.77; '3.4': 0.84; 'demonstrates': 0.84; 'find.': 0.84; 'bounces': 0.91 X-Gm-Message-State: ALoCoQlt3oHvpCjeRN7uKJlxZrIUuqnDqPCh5ao8c3COzA9wwl0zebTa8insCchA2lKREMnWrKLW X-Received: by 10.180.109.130 with SMTP id hs2mr5754246wib.54.1418375137373; Fri, 12 Dec 2014 01:05:37 -0800 (PST) MIME-Version: 1.0 From: Stefanos Karasavvidis Date: Fri, 12 Dec 2014 11:05:17 +0200 Subject: encoding name mappings in codecs.py with email/charset.py To: Content-Type: multipart/alternative; boundary="089e0102e1f838c77f050a013242" X-Originating-IP: [209.85.212.170] X-Mailman-Approved-At: Fri, 12 Dec 2014 10:21:00 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418376062 news.xs4all.nl 2924 [2001:888:2000:d::a6]:59689 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82431 --089e0102e1f838c77f050a013242 Content-Type: text/plain; charset="UTF-8" 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: given an encoding name as 'iso-8859-X' it is transformed to 'iso8859-X' (without the first dash). This happens with python 2.7, but not with python 3.4. Now Microsoft Exchange doesn't like the form without the dash, and bounces the emails from Mailman. And Mailman doesn't work with python 3.x. This transformation is done in charset.py with the following line input_charset = codecs.lookup(input_charset).name The following code example demonstrates the issue from email.charset import Charset charset = Charset('iso-8859-7') print(str(charset)) In python 2.7, iso8859-7 is printed. In python 3.4 iso-8859-7 is printed. I tried to find the location of these mappings in the codecs.py file, but it seems that it uses some internal mapping I couldn't find. And I'm not 100% sure that this is not OS related. So the question basically is if there is a way to change the name mappings this codecs file does. My environment is Ubuntu 14.04 python2.7 --version Python 2.7.6 python3.4 --version Python 3.4.0 -- ====================================================================== Stefanos Karasavvidis, Electronic & Computer Engineer, M.Sc. e-mail: sk@isc.tuc.gr, Tel.: (+30) 2821037508, Fax: (+30) 2821037520 Technical University of Crete, Campus, Building A1 --089e0102e1f838c77f050a013242 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've hit a wall with mailman which seems to be ca= used by pyhon's character encoding names.

I've narrowed the = problem down to the email/charset.py file. Basically the following happens:=

given an encoding name as 'iso-8859-X' it is transfor= med to 'iso8859-X' (without the first dash). This happens with pyth= on 2.7, but not with python 3.4. Now Microsoft Exchange doesn't like th= e form without the dash, and bounces the emails from Mailman. And Mailman d= oesn't work with python 3.x.

This transformation is done in char= set.py with the following line
input_charset =3D codecs.lookup(input_cha= rset).name

The following code exa= mple demonstrates the issue
=C2=A0=C2=A0 from email.charset import Chars= et
=C2=A0=C2=A0 charset =3D Charset('iso-8859-7')
=C2=A0=C2= =A0 print(str(charset))

In python 2.7, iso8859-7 is print= ed. In python 3.4 iso-8859-7 is printed.

I tried to find = the location of these mappings in the codecs.py file, but it seems that it = uses some internal mapping I couldn't find. And I'm not 100% sure t= hat this is not OS related.

So the question basically is = if there is a way to change the name mappings this codecs file does.

My environment is Ubuntu 14.04
python2.7 --version
Python= 2.7.6

python3.4 --version
Python 3.4.0

--
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
Stefanos Karasavvidis,=C2=A0 = Electronic & Computer= Engineer, M.Sc.
e-mail: sk@isc.tuc.gr, T= el.: (+30) 2821037508, Fax: (+30) 2821037520
Technical University of Crete, Campus, Building A1

--089e0102e1f838c77f050a013242--