Opened 17 years ago
Closed 17 years ago
#3664 closed defect (fixed)
Typo in email_distributor.py fails to load email.Header
| Reported by: | anonymous | Owned by: | Robert Corsaro | 
|---|---|---|---|
| Priority: | normal | Component: | AnnouncerPlugin | 
| Severity: | major | Keywords: | header | 
| Cc: | Trac Release: | 0.11 | 
Description
Typo on line 15 of distributors/email_distributor.py has lower case 'header' which fails to properly load header module.
Fix is to change line 15 from:
import email.header import Header
to:
from email.Header import Header
Attachments (1)
Change History (15)
comment:1 Changed 17 years ago by
comment:2 Changed 17 years ago by
Are you sure? Try
$ cd ${trachacksco}/annoucerplugin/0.11
$ svn revert . -R
$ svn up
    comment:3 Changed 17 years ago by
I just exported and built from HEAD, made capitalisation fix, and I get this error. My default_charset is iso-8859-15.
comment:4 Changed 17 years ago by
oh, you have type above, me thinks. That's why I was confused. Let me look into it. You had:
import email.header import Header
I thought the first import was the error and couldn't find it.
comment:5 Changed 17 years ago by
My apologies. I have discovered that self.env.config.get() returns a unicode object, which is what is choking up unicode() in the Charset class. While I'm a developer, I'm not a python developer -- so I'm not immediately sure how to fix that. :)
comment:6 follow-up: 10 Changed 17 years ago by
I got around the traceback by adding these lines right after the charset is determined in _do_send():
if isinstance(charset, unicode):
charset = charset.encode()
However, now I'm back to experiencing the problem described in #3560.
comment:7 Changed 17 years ago by
What version of python are you using? I'm on python-2.5.2-r7 and it is definitely email.header (lowercase). Looking at the init.py I see this:
#python
_LOWERNAMES = [
    # email.<old name> -> email.<new name is lowercased old name>
    'Charset',
    'Encoders',
    'Errors',
    'FeedParser',
    'Generator',
    'Header',
    'Iterators',
    'Message',
    'Parser',
    'Utils',
    'base64MIME',
    'quopriMIME',
    ]
Looks like it used to be uppercase but recently changed to lowercase.
comment:8 Changed 17 years ago by
better:
_LOWERNAMES = [ # email.<old name> -> email.<new name is lowercased old name> 'Charset', 'Encoders', 'Errors', 'FeedParser', 'Generator', 'Header', 'Iterators', 'Message', 'Parser', 'Utils', 'base64MIME', 'quopriMIME', ]
comment:9 Changed 17 years ago by
Here is a patch for ppl using an old version of the python mail module.
Changed 17 years ago by
| Attachment: | announcerplugin-old_email_module_compat.diff added | 
|---|
Use old style email module names
comment:10 Changed 17 years ago by
| Keywords: | header added | 
|---|
Replying to anonymous:
I got around the traceback by adding these lines right after the charset is determined in _do_send():
if isinstance(charset, unicode):
charset = charset.encode()
However, now I'm back to experiencing the problem described in #3560.
I changed the case of the word 'header' on line 15, then did this and I have finally gotten the html email to work. I am using CentOS 5.2, python 2.4, Trac 0.11stable-r7368. At this point I am seeing no errors. I currently have all components enabled except JoinableGroupSubscriber. I pulled the latest code from svn and made my changes to that.
Just thought another data point might help.
comment:11 Changed 17 years ago by
BTW, I forgot to log in, so I am showing up as anonymous in the last comment, was a different anonymous from the one that I was quoting in the comment. :)
comment:14 Changed 17 years ago by
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 




Fixing typo causes following Traceback:
Traceback (most recent call last): File "build/bdist.linux-i686/egg/announcerplugin/api.py", line 377, in _real_send File "build/bdist.linux-i686/egg/announcerplugin/distributors/email_distributor.py", line 195, in distribute File "build/bdist.linux-i686/egg/announcerplugin/distributors/email_distributor.py", line 250, in _do_send File "/usr/lib/python2.4/email/Header.py", line 161, in __init__ charset = Charset(charset) File "/usr/lib/python2.4/email/Charset.py", line 190, in __init__ input_charset = unicode(input_charset, 'ascii').lower() TypeError: decoding Unicode is not supported