[PATCH] models: Fix HeaderParser import on python 2.4

Sabuj Pattanayek sabujp at gmail.com
Tue Nov 9 07:00:23 EST 2010


Hi,

I applied the patch, actually ran git pull (saw that the new models.py
hadd your additions), then manage.py syncdb (verified that the new
entries went into patchwork_patch, e.g. pull_url), then restarted
httpd, but still getting the headerparser import error when clicking
the mbox link for a patch :

Environment:

Request Method: GET
Request URL: http://patchwork.meilerlab.org/patch/313/mbox/
Django Version: 1.2 SVN-14395
Python Version: 2.4.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'patchwork',
 'registration']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware')


Traceback:
File "/blue/meilerlab/home/patchwork/lib/python/django/core/handlers/base.py"
in get_response
  100.                     response = callback(request,
*callback_args, **callback_kwargs)
File "/blue/meilerlab/home/patchwork/apps/patchwork/views/patch.py" in mbox
  123.     response.write(patch.mbox().as_string(True))
File "/blue/meilerlab/home/patchwork/apps/patchwork/models.py" in mbox
  277.         orig_headers = HeaderParser().parsestr(str(self.headers))

Exception Type: NameError at /patch/313/mbox/
Exception Value: global name 'HeaderParser' is not defined

Thanks,
Sabuj

On Tue, Nov 2, 2010 at 12:27 PM, Jeremy Kerr <jk at ozlabs.org> wrote:
> We need to add an import for HeaderParser on python 2.4; email.Parser
> appears to contain the right stuff.
>
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
>
> ---
>  apps/patchwork/models.py |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py
> index edb52df..6842622 100644
> --- a/apps/patchwork/models.py
> +++ b/apps/patchwork/models.py
> @@ -38,6 +38,7 @@ except ImportError:
>     # Python 2.4 compatibility
>     from email.MIMENonMultipart import MIMENonMultipart
>     from email.Encoders import encode_7or8bit
> +    from email.Parser import HeaderParser
>     import email.Utils
>     email.utils = email.Utils
>
>


More information about the Patchwork mailing list