[Spambayes] Mailbox class in the spambayes project & python 2.2.1

Guido van Rossum guido@python.org
Wed, 25 Sep 2002 12:51:26 -0400


> On Wed, 25 Sep 2002 11:58:36 -0400 Guido van Rossum <guido@python.org>
> wrote:
> 
> > Content-Type: multipart/signed; micalg*=ansi-x3-4-1968''pgp-md5;
> > 	protocol*=ansi-x3-4-1968''application%2Fpgp-signature;
> > 	boundary*="ansi-x3-4-1968''EeQfGwPcQSOJBaQU"
> 
> > This fails because in this case, boundary is the tuple
> > ('ansi-x3-4-1968', '', 'EeQfGwPcQSOJBaQU') where the actual boundary
> > is the third element.  (The first is an encoding, a fancy name for
> > ASCII AFAICT; the second is an optional natural language.)
> 
> This means the boundary is encoded with ansi-x3-4-1968? So get_boundary()
> is supposed to return ansi_x3_4_1968.decode(boundary) with the actual API?

I tried this:

  if isinstance(x, tuple):
     assert len(x) == 3
     x = unicode(x[2], x[0]).encode('ascii')

but this didn't work because while Python's encodings package knows
'ansi_x3.4_1968' and 'ansi_x3.4_1986' (sic) as aliases for 'ascii', it
doesn't know 'ansi-x3-4-1968'. :-(

I've added this to Lib/encodings/aliases.py in the 2.3 trunk and 2.2.2
branch, but that wouldn't help current deployment using 2.2.1 or even
2.2, which we're currently aiming for.

I consider this a buglet in Goblin's mailer: things like charset names
and boundaries are supposed to be ASCII according to the MIME
standard, and he is unnecessarily explicit about this encoding.

--Guido van Rossum (home page: http://www.python.org/~guido/)