Skip to content

Commit 057ae85

Browse files
author
Release Manager
committed
gh-41023: 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 <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #41023 Reported by: Chenxin Zhong Reviewer(s): Copilot, Dima Pasechnik
2 parents 0eeaf12 + b30e0b0 commit 057ae85

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/sage/doctest/external.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
3838
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
3939
# trac #27754.
40-
if platform.system() == 'Darwin':
41-
multiprocessing.set_start_method('fork', force=True)
40+
# With Python 3.14, the default changed to 'forkserver' on Linux as well.
41+
# Sage doctesting requires 'fork' method.
42+
multiprocessing.set_start_method('fork', force=True)
4243
Array = multiprocessing.Array
4344

4445
# Functions in this module whose name is of the form 'has_xxx' tests if the

src/sage/doctest/forker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@
9191
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
9292
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
9393
# trac #27754.
94-
if platform.system() == 'Darwin':
95-
multiprocessing.set_start_method('fork', force=True)
94+
# With Python 3.14, the default changed to 'forkserver' on Linux as well.
95+
# Sage doctesting requires 'fork' method.
96+
multiprocessing.set_start_method('fork', force=True)
9697

9798

9899
def _sorted_dict_pprinter_factory(start, end):

0 commit comments

Comments
 (0)