Edgewall Software
Modify

Opened 5 months ago

Closed 4 months ago

#13763 closed defect (fixed)

NotificationTestCase.test_multiline_header failing with Python 3.12.4

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: not applicable
Component: notification Version: 1.6
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

The test failure occurs with Python 3.12.4 but not with 3.12.3. I think something wrong is introduced in 3.12.4.

  Package        Version
  ---------------------------------------------------------------
  Python       : 3.12.4 (main, Jun  8 2024, 18:29:57) [GCC 9.4.0]
  Setuptools   : 70.0.0
  Pip          : 24.0
  Wheel        : 0.43.0
  Jinja2       : 3.1.4
  multipart    : 0.2.4
  Babel        : 2.15.0
  sqlite3      : 2.6.0 (3.31.1)
  PySqlite3    : 0.5.2 (3.35.5)
  PyMySQL      : 1.4.6
  Psycopg2     : 2.9.9 (dt dec pq3 ext lo64)
  SVN bindings : 1.14.2 (r1899510)
  Mercurial    : 6.7.3
  Pygments     : 2.18.0
  Textile      : 4.0.2
  Pytz         : 2024.1
  Docutils     : 0.21.2
  aiosmtpd     : 1.4.6
  Selenium     : 4.21.0
  PyTidyLib    : 0.3.2 (5.6.0 libtidy.so.5deb1)
  LXML         : not installed
  coverage     : 7.5.3

Variables:
  PATH=/home/jun66j5/venv/py312/bin:/home/jun66j5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
  PYTHONPATH=.
  TRAC_TEST_DB_URI=
  server-options= -p 3000  --basic-auth='*,/home/jun66j5/src/trac/htpasswd.txt,auth' -e

External dependencies:
  Git version: git version 2.45.2
  Subversion version: 1.14.2

SKIP_FUNCTIONAL_TESTS=1 python -Wdefault -m unittest  trac.test.test_suite
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sss....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s.................................................................s.......................................................................................................................
======================================================================
FAIL: test_multiline_header (trac.ticket.tests.notification.NotificationTestCase.test_multiline_header)
Encoded headers split into multiple lines
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/svn/1.6-stable/trac/ticket/tests/notification.py", line 730, in test_multiline_header
    self.assertEqual(ticket['summary'], summary)
AssertionError: 'A_ve[49 chars]ong long long long long long long long long long long súmmäry' != 'A_ve[49 chars]ong long long long long long long long long long long súmm äry'
- A_very long long long long long long long long long long long long long long long long long long long long súmmäry
+ A_very long long long long long long long long long long long long long long long long long long long long súmm äry
?                                                                                                                +


----------------------------------------------------------------------
Ran 2804 tests in 32.683s

FAILED (failures=1, skipped=5)

Attachments (0)

Change History (4)

comment:1 by Jun Omae, 5 months ago

Minimal reproducible example:

Python 3.12.3 (main, May 23 2024, 00:56:56) [GCC 13.2.1 20240309] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email import message_from_string
>>> from email.message import EmailMessage
>>> from email.header import decode_header, make_header
>>> msg = EmailMessage()
>>> msg.set_content(u'Body text.\n', cte='quoted-printable')
>>> subject = 'A_very' + ' long' * 23 + ' súmmäry'
>>> subject
'A_very long long long long long long long long long long long long long long long long long long long long long long long súmmäry'
>>> msg['Subject'] = subject
>>> print(msg.as_string())
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: A_very long long long long long long long long long long long long
 long long long long long long long long long long long =?utf-8?q?s=C3=BAmm?=
 =?utf-8?q?=C3=A4ry?=

Body text.

>>> parsed_msg = message_from_string(msg.as_string())
>>> parsed_subject = str(make_header(decode_header(parsed_msg['Subject'])))
>>> parsed_subject
'A_very long long long long long long long long long long long long long long long long long long long long long long long súmmäry'
>>> subject == parsed_subject
True
>>>
Python 3.12.4 (main, Jun 20 2024, 23:12:11) [GCC 13.2.1 20240309] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email import message_from_string
>>> from email.message import EmailMessage
>>> from email.header import decode_header, make_header
>>> msg = EmailMessage()
>>> msg.set_content(u'Body text.\n', cte='quoted-printable')
>>> subject = 'A_very' + ' long' * 23 + ' súmmäry'
>>> subject
'A_very long long long long long long long long long long long long long long long long long long long long long long long súmmäry'
>>> msg['Subject'] = subject
>>> print(msg.as_string())
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: A_very long long long long long long long long long long long long
 long long long long long long long long long long long =?utf-8?q?s=C3=BAmm?=
 =?utf-8?q?_?==?utf-8?q?=C3=A4ry?=

Body text.

>>> parsed_msg = message_from_string(msg.as_string())
>>> parsed_subject = str(make_header(decode_header(parsed_msg['Subject'])))
>>> parsed_subject
'A_very long long long long long long long long long long long long long long long long long long long long long long long súmm äry'
>>> subject == parsed_subject
False
>>>

comment:3 by Jun Omae, 5 months ago

Milestone: 1.6.1next-stable-1.6.x

Skipped this test with Python 3.12.4 in [17827].

comment:4 by Jun Omae, 4 months ago

Milestone: next-stable-1.6.xnot applicable
Resolution: fixed
Status: assignedclosed

The root cause has been fixed in Python 3.12 branch (https://github.com/python/cpython/pull/121964).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.