Skip to content

Commit b30e0b0

Browse files
committed
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
1 parent 4e2319b commit b30e0b0

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)