From b30e0b082cd837a2f85e3f85908d953726368c0d Mon Sep 17 00:00:00 2001 From: cxzhong Date: Fri, 10 Oct 2025 11:33:40 +0800 Subject: [PATCH] Fix multiprocessing start method for Python 3.14 compatibility Python 3.14 changed the default multiprocessing start method from 'fork' to 'forkserver' on Linux. This caused pickling errors in the doctest framework because DocTestWorker objects contained unpicklable local functions. The fix ensures that the 'fork' start method is always used on all platforms, not just macOS, since Sage's doctesting framework requires the 'fork' method to function correctly. Changes: - src/sage/doctest/forker.py: Remove Darwin-only check, always use fork - src/sage/doctest/external.py: Remove Darwin-only check, always use fork --- src/sage/doctest/external.py | 5 +++-- src/sage/doctest/forker.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sage/doctest/external.py b/src/sage/doctest/external.py index 45803b9e76a..81107ecc812 100644 --- a/src/sage/doctest/external.py +++ b/src/sage/doctest/external.py @@ -37,8 +37,9 @@ # With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in # multiprocessing, and Sage doctesting doesn't work with 'spawn'. See # trac #27754. -if platform.system() == 'Darwin': - multiprocessing.set_start_method('fork', force=True) +# With Python 3.14, the default changed to 'forkserver' on Linux as well. +# Sage doctesting requires 'fork' method. +multiprocessing.set_start_method('fork', force=True) Array = multiprocessing.Array # Functions in this module whose name is of the form 'has_xxx' tests if the diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index 22c58126386..884a694aa53 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -91,8 +91,9 @@ # With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in # multiprocessing, and Sage doctesting doesn't work with 'spawn'. See # trac #27754. -if platform.system() == 'Darwin': - multiprocessing.set_start_method('fork', force=True) +# With Python 3.14, the default changed to 'forkserver' on Linux as well. +# Sage doctesting requires 'fork' method. +multiprocessing.set_start_method('fork', force=True) def _sorted_dict_pprinter_factory(start, end):