Bug 2318976 - Mailman3 fails to start with Python 3.13
Summary: Mailman3 fails to start with Python 3.13
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: mailman3
Version: 41
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2024-10-15 21:16 UTC by Göran Uddeborg
Modified: 2025-05-24 09:47 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gitlab mailman mailman issues 1176 0 None opened python 3.13 drops nntplib 2024-11-13 18:39:34 UTC

Description Göran Uddeborg 2024-10-15 21:16:10 UTC
After upgrading to Python 3.13, I'm not able to run mailman3 any more.

Reproducible: Always

Steps to Reproduce:
1.sudo -u mailman mailman3 conf

(The regular service also fails to start, but this is a simple command-line reproducer.)
Actual Results:  
A backtrace ending in

  File "/usr/lib/python3.13/site-packages/mailman/commands/cli_gatenews.py", line 24, in <module>
    import nntplib
ModuleNotFoundError: No module named 'nntplib'


Expected Results:  
A printout of the configuration.

"nntplib" is imported in mailman/commands/cli_gatenews.py, but the "nntplib" library is removed in Python 3.13. I'm not the first to discover this as there is an upstreams bug https://gitlab.com/mailman/mailman/-/issues/1176 but I couldn't find any report here in Bugzilla.

Comment 1 Michel Lind 2024-11-13 18:36:40 UTC
Oof. Thanks for reporting!

Comment 2 Miro Hrončok 2025-04-01 10:40:32 UTC
From the spec file:


  # Tests fail with nspawn mock due to lack of access to /dev/stdout
  # TODO: Figure out a fix for this
  venv/bin/python -m nose2 -v || :

From the build log:

  ======================================================================
  ERROR: mailman.commands.tests.test_cli_gatenews (nose2.loader.ModuleImportFailure.mailman.commands.tests.test_cli_gatenews)
  ----------------------------------------------------------------------
  ImportError: Failed to import test module: mailman.commands.tests.test_cli_gatenews
  Traceback (most recent call last):
    File "/usr/lib/python3.13/site-packages/nose2/plugins/loader/discovery.py", line 195, in _find_tests_in_file
      module = util.module_from_name(module_name)
    File "/usr/lib/python3.13/site-packages/nose2/util.py", line 73, in module_from_name
      __import__(name)
      ~~~~~~~~~~^^^^^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/commands/tests/test_cli_gatenews.py", line 21, in <module>
      import nntplib
  ModuleNotFoundError: No module named 'nntplib'
  ======================================================================
  ERROR: test_opening_character_device (mailman.core.tests.test_logging.TestRunner.test_opening_character_device)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/core/tests/test_logging.py", line 28, in test_opening_character_device
      handler = ReopenableFileHandler('test', '/dev/stdout')
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/core/logging.py", line 51, in __init__
      self._stream = self._open()
                     ~~~~~~~~~~^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/core/logging.py", line 64, in _open
      return codecs.open(self.filename, open_mode, 'utf-8')
             ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen codecs>", line 921, in open
  PermissionError: [Errno 13] Permission denied: '/dev/stdout'
  ======================================================================
  ERROR: mailman.runners.tests.test_nntp (nose2.loader.ModuleImportFailure.mailman.runners.tests.test_nntp)
  ----------------------------------------------------------------------
  ImportError: Failed to import test module: mailman.runners.tests.test_nntp
  Traceback (most recent call last):
    File "/usr/lib/python3.13/site-packages/nose2/plugins/loader/discovery.py", line 195, in _find_tests_in_file
      module = util.module_from_name(module_name)
    File "/usr/lib/python3.13/site-packages/nose2/util.py", line 73, in module_from_name
      __import__(name)
      ~~~~~~~~~~^^^^^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/runners/tests/test_nntp.py", line 21, in <module>
      import nntplib
  ModuleNotFoundError: No module named 'nntplib'
  ======================================================================
  ERROR: LayerSuite
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/testing/layers.py", line 135, in setUp
      initialize.initialize_2(testing=True)
      ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/core/initialize.py", line 199, in initialize_2
      initialize_commands()
      ~~~~~~~~~~~~~~~~~~~^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/app/commands.py", line 29, in initialize
      add_components('commands', IEmailCommand, config.commands)
      ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/utilities/modules.py", line 218, in add_components
      for component_class in find_pluggable_components(subpackage, interface):
                             ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/utilities/modules.py", line 177, in find_pluggable_components
      yield from find_components('mailman.' + subpackage, interface)
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/utilities/modules.py", line 150, in find_components
      module = import_module(module_name)
    File "/usr/lib64/python3.13/importlib/__init__.py", line 88, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
             ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "/builddir/build/BUILD/mailman3-3.3.9-build/mailman-3.3.9/src/mailman/commands/cli_gatenews.py", line 24, in <module>
      import nntplib
  ModuleNotFoundError: No module named 'nntplib'
  ----------------------------------------------------------------------
  Ran 53 tests in 0.275s
  FAILED (errors=4)


------------------


I believe the original reason for ignoring the test results is no longer valid.

If this was not ignored, we would have known about this problem a year ago. Please don't do that.

This is explicitly forbidden by the guidelines https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_running_tests -- exactly for this reason.

Comment 3 Sjoerd Mullender 2025-05-21 07:30:56 UTC
If you don't actually need NNTP support, the easiest way to get on your way is to add

[runner.nntp]
start: no

to your mailman.cfg file, and to create an empty file /usr/lib/python3.13/site-packages/nntplib.py

This is not a fix, this is a workaround.

Comment 4 Göran Uddeborg 2025-05-24 09:47:16 UTC
Thanks for that workaround! I helps me, and I suspect potentially many others.


Note You need to log in before you can comment on or make changes to this bug.