Modify

Opened 6 years ago

Closed 6 years ago

#3664 closed defect (fixed)

Typo in email_distributor.py fails to load email.Header

Reported by: anonymous Owned by: doki_pen
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)

announcerplugin-old_email_module_compat.diff (551 bytes) - added by doki_pen 6 years ago.
Use old style email module names

Download all attachments as: .zip

Change History (15)

comment:1 Changed 6 years ago by anonymous

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

comment:2 Changed 6 years ago by anonymous

Are you sure? Try

$ cd ${trachacksco}/annoucerplugin/0.11
$ svn revert . -R
$ svn up

comment:3 Changed 6 years ago by anonymous

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 6 years ago by anonymous

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 6 years ago by anonymous

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: Changed 6 years ago by 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.

comment:7 Changed 6 years ago by doki_pen

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 6 years ago by anonymous

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 6 years ago by doki_pen

Here is a patch for ppl using an old version of the python mail module.

Changed 6 years ago by doki_pen

Use old style email module names

comment:10 in reply to: ↑ 6 Changed 6 years ago by anonymous

  • 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 6 years ago by jbdfw

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:12 Changed 6 years ago by acamac

Had same problem, using Python 2.4.3
Had to implement 3929 too.

comment:13 Changed 6 years ago by doki_pen

fixed in r4896

comment:14 Changed 6 years ago by anonymous

  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.