Code

Opened 10 months ago

Closed 7 months ago

Last modified 5 months 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: master
Severity: Release blocker Keywords:
Cc: Arfrever, apollo13 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.

Attachments (0)

Change History (11)

comment:1 Changed 10 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

comment:2 Changed 10 months ago by Arfrever

  • Cc Arfrever added

comment:3 Changed 10 months ago by apollo13

  • Cc apollo13 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 Changed 10 months ago by apollo13

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

comment:5 Changed 7 months ago by apollo13

  • Severity changed from Normal to Release blocker
  • Version changed from 1.5 to master

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

comment:6 Changed 7 months ago by Florian Apolloner <florian@…>

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

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 Changed 7 months ago by Florian Apolloner <florian@…>

In 280c1a65ccacd679bf298bf2b169ff01e7266b8e:

Worked around a bug in python 3.3.3. Refs #21093

comment:8 Changed 7 months ago by Florian Apolloner <florian@…>

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 Changed 7 months ago by Florian Apolloner <florian@…>

In ed167e53a52af22a8dce229696184b0d87a88a78:

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

Backport of 280c1a65ccacd679bf298bf2b169ff01e7266b8e from master.

comment:10 Changed 5 months ago by cainmatt@…

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 Changed 5 months ago by apollo13

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 ;))?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


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

 
Note: See TracTickets for help on using tickets.