From 9538996dea0c4ea536a8df6292eb90b6a52a6ca7 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Sat, 30 Jan 2016 22:35:20 -0800 Subject: [PATCH] Fixes build failures on Python 3.x. Squashed commit of the following: commit f3a782d0b0a338edd188bddd1258074579343173 Author: Adam Coddington Date: Sat Jan 30 22:32:51 2016 -0800 Django 1.7 does not support Python 3.5. commit c100ccf86792e9181404431f0767186e4eaa5c98 Author: Adam Coddington Date: Sat Jan 30 22:28:09 2016 -0800 Ensure that message_id is always stripped. commit ee5a023da10cf4e95828eed5f32f4cf5e8419fe5 Author: Adam Coddington Date: Sat Jan 30 22:24:27 2016 -0800 Modern python versions do not have --use-mirrors. commit 54aa74d9848d4e8b57c525c1ab31b6541322217e Author: Adam Coddington Date: Sat Jan 30 22:19:59 2016 -0800 Turn off sudo mode for django-mailbox. --- .travis.yml | 7 +++++-- django_mailbox/models.py | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76653a1..a7c2eec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ matrix: python: '3.5' - env: DJANGO='>=1.7,<1.8' python: '2.6' + - env: DJANGO='>=1.7,<1.8' + python: '3.5' - env: DJANGO='>=1.8,<1.9' python: '2.6' - env: DJANGO='>=1.9,<1.10' @@ -35,7 +37,8 @@ matrix: - env: DJANGO='>=1.9,<1.10' python: '3.4' install: -- pip install -q Django$DJANGO --use-mirrors -- pip install -q -e . --use-mirrors +- pip install -q Django$DJANGO +- pip install -q -e . script: - python setup.py test +sudo: false diff --git a/django_mailbox/models.py b/django_mailbox/models.py index e9cb9fd..ce218de 100644 --- a/django_mailbox/models.py +++ b/django_mailbox/models.py @@ -367,7 +367,7 @@ class Mailbox(models.Model): if 'subject' in message: msg.subject = convert_header_to_unicode(message['subject'])[0:255] if 'message-id' in message: - msg.message_id = message['message-id'][0:255] + msg.message_id = message['message-id'][0:255].strip() if 'from' in message: msg.from_header = convert_header_to_unicode(message['from']) if 'to' in message: @@ -380,7 +380,7 @@ class Mailbox(models.Model): if message['in-reply-to']: try: msg.in_reply_to = Message.objects.filter( - message_id=message['in-reply-to'] + message_id=message['in-reply-to'].strip() )[0] except IndexError: pass @@ -560,7 +560,7 @@ class Message(models.Model): message.from_email = settings.DEFAULT_FROM_EMAIL message.extra_headers['Message-ID'] = make_msgid() message.extra_headers['Date'] = formatdate() - message.extra_headers['In-Reply-To'] = self.message_id + message.extra_headers['In-Reply-To'] = self.message_id.strip() message.send() return self.mailbox.record_outgoing_message( email.message_from_string(