Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21093 closed Bug (fixed)

regressiontests.mail.tests.MailTests.test_dont_base64_encode() fails with Python >=3.3.3

Reported by: Arfrever Owned by: nobody
Component: Testing framework Version: dev
Severity: Release blocker Keywords:
Cc: Arfrever, Florian Apolloner Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

regressiontests.mail.tests.MailTests.test_dont_base64_encode() fails with Python >=3.3.3 since Python commit 64e004737837.
It passes with older versions of Python.
I use Django 1.5.3.

$ PYTHONPATH="." python3.3 tests/runtests.py --settings=test_sqlite -v0 mail.MailTests.test_dont_base64_encode
======================================================================
FAIL: test_dont_base64_encode (regressiontests.mail.tests.MailTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/Django-1.5.3/tests/regressiontests/mail/tests.py", line 330, in test_dont_base64_encode
    self.assertTrue(str('Content-Transfer-Encoding: 8bit') in s)
AssertionError: False is not True

----------------------------------------------------------------------
Ran 1 test in 0.025s

FAILED (failures=1)

Variable 's' contains 'Content-Transfer-Encoding: 8bit' with older versions of Python and 'Content-Transfer-Encoding: 7bit' with Python >=3.3.3.

Change History (11)

comment:1 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 by Arfrever, 11 years ago

Cc: Arfrever added

comment:3 by Florian Apolloner, 11 years ago

Cc: Florian Apolloner added

I think get_payload in python shouldn't decode the message, I am in contact with the author of the patch, hopefully we can get that fixed for python 3.3.3 :)

comment:4 by Florian Apolloner, 11 years ago

Waiting for the outcome of http://bugs.python.org/issue19063

comment:5 by Florian Apolloner, 11 years ago

Severity: NormalRelease blocker
Version: 1.5master

We should review if our smtp backend properly sends mails on python 3.3+

comment:6 by Florian Apolloner <florian@…>, 11 years ago

Resolution: fixed
Status: newclosed

In f28ea0230846c81e9b6725454bb3a10df24678aa:

Fixed #21093 -- Ensured that mails are not base64 encoded on python 3.3.3+.

Thanks to Arfrever for the report and Aymeric for the review.

comment:7 by Florian Apolloner <florian@…>, 11 years ago

In 280c1a65ccacd679bf298bf2b169ff01e7266b8e:

Worked around a bug in python 3.3.3. Refs #21093

comment:8 by Florian Apolloner <florian@…>, 11 years ago

In 35a447a263115b22a7040a9f4a16ff4bd2078466:

[1.6.x] Fixed #21093 -- Ensured that mails are not base64 encoded on python 3.3.3+.

Thanks to Arfrever for the report and Aymeric for the review.

Backport of f28ea0230846c81e9b6725454bb3a10df24678aa from master.

comment:9 by Florian Apolloner <florian@…>, 11 years ago

In ed167e53a52af22a8dce229696184b0d87a88a78:

[1.6.x] Worked around a bug in python 3.3.3. Refs #21093

Backport of 280c1a65ccacd679bf298bf2b169ff01e7266b8e from master.

comment:10 by cainmatt@…, 11 years ago

regarding message.py:

I think that rather than re-encoding the message in SafeMimeText you should set the encoding globally for python using:

Charset.add_charset('utf-8', Charset.SHORTEST, None, 'utf-8')

Note:

u1 = Charset.Charset('utf-8')
u1.body_encoding = None
u2 = Charset.Charset('utf-8')

u2.body_encoding != u1.body_encoding

comment:11 by Florian Apolloner, 11 years ago

See https://github.com/django/django/blob/280c1a65ccacd679bf298bf2b169ff01e7266b8e/django/core/mail/message.py#L26 -- we purposely don't want to change anything globally. also are you talking about the 3.3.3 fix, or the 3.3.3+ fix and how exactly would your patch look like (and why would it be better than what we have now and would the tests pass ;))?

Note: See TracTickets for help on using tickets.
Back to Top