[Email-SIG] bug possibility

Eric S. Johansson esj at harvee.org
Wed Apr 21 15:42:12 EDT 2004

you might not consider this a bug but it certainly is biting me hard.

with python 2.2.3 stock e-mail module and the 2.5.4 module, I get the 
same result (not surprising since I hear they're almost the same anyway)

given the following message (shell script for generating message 
available on request)

Received: (from esj at localhost)
         by redweb.harvee.org (8.12.10/8.12.10/Submit) id i3LJBP3v009690
         for root at redweb.harvee.org; Wed, 21 Apr 2004 15:11:25 -0400
Date: Wed, 21 Apr 2004 15:11:25 -0400
From: esj at redweb.harvee.org
Message-Id: <200404211911.i3LJBP3v009690 at redweb.harvee.org>
To: root at redweb.harvee.org


when I retrieve the message with as_string, I get:

Traceback (most recent call last):
   File "/usr/lib/python2.2/site-packages/Milter.py", line 188, in <lambda>
     milter.set_eom_callback(lambda ctx: ctx.getpriv().eom())
   File "./milter_daemon.py", line 94, in eom
     if camram_pymilter.do_filter(msg, self.mailfrom):
   File "./camram_pymilter.py", line 76, in do_filter
     spamtrap.insert( message )
   File "/home/esj/camram_core/modules/camram_utils.py", line 309, in insert
   File "/usr/lib/python2.2/site-packages/email/Message.py", line 113, 
in as_string
     g.flatten(self, unixfrom=unixfrom)
   File "/usr/lib/python2.2/site-packages/email/Generator.py", line 103, 
in flatten
   File "/usr/lib/python2.2/site-packages/email/Generator.py", line 138, 
in _write
   File "/usr/lib/python2.2/site-packages/email/Generator.py", line 184, 
in _write_headers
     header_name=h, continuation_ws='\t').encode()
   File "/usr/lib/python2.2/site-packages/email/Header.py", line 412, in 
     newchunks += self._split(s, charset, targetlen, splitchars)
   File "/usr/lib/python2.2/site-packages/email/Header.py", line 297, in 
     elen = charset.encoded_header_len(encoded)
   File "/usr/lib/python2.2/site-packages/email/Charset.py", line 341, 
in encoded_header_len
     return len(s)
TypeError: len() of unsized object

however, if I turn off the header wrapping in as_string (g = 
Generator(fp, maxheaderlen=0) the problem goes away.

yes, I have a ugly workaround or two for the problem but it still my 
opinion that this problem shouldn't happen.

The workarounds I have are hack the original code, derive from the 
original message code and overload the as_string method.  I gathered 
there is some magic one can use with generators that would be useful in 
fixing this problem but so far, that escapes me.  Enlightenment would be 


More information about the Email-SIG mailing list