From 6f529f01edee46be471a53e83dcfa6181654a883 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 1 Dec 2019 15:19:25 +0900 Subject: [PATCH] Fix #6803: Disable parallel build on macOS and py38+ --- CHANGES | 4 ++++ sphinx/application.py | 7 +++++++ sphinx/util/parallel.py | 9 ++++++++- tests/test_util_logging.py | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 920312b5d..f22b6d67b 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,9 @@ Dependencies Incompatible changes -------------------- +* #6803: For security reason of python, parallel mode is disabled on macOS and + Python3.8+ + Deprecated ---------- @@ -19,6 +22,7 @@ Bugs fixed * #6776: LaTeX: 2019-10-01 LaTeX release breaks :file:`sphinxcyrillic.sty` * #6815: i18n: French, Hindi, Japanese and Korean translation messages has been broken +* #6803: parallel build causes AttributeError on macOS and Python3.8 Testing -------- diff --git a/sphinx/application.py b/sphinx/application.py index 1c7a05357..96dd3948d 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -12,6 +12,7 @@ import os import pickle +import platform import sys import warnings from collections import deque @@ -199,6 +200,12 @@ class Sphinx: # say hello to the world logger.info(bold(__('Running Sphinx v%s') % sphinx.__display_version__)) + # notice for parallel build on macOS and py38+ + if sys.version_info > (3, 8) and platform.system() == 'Darwin' and parallel > 1: + logger.info(bold(__("For security reason, parallel mode is disabled on macOS and " + "python3.8 and above. For more details, please read " + "https://github.com/sphinx-doc/sphinx/issues/6803"))) + # status code for command-line application self.statuscode = 0 diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py index 2d519a8d3..0ff0ec116 100644 --- a/sphinx/util/parallel.py +++ b/sphinx/util/parallel.py @@ -9,6 +9,8 @@ """ import os +import platform +import sys import time import traceback from math import sqrt @@ -26,7 +28,12 @@ logger = logging.getLogger(__name__) # our parallel functionality only works for the forking Process -parallel_available = multiprocessing and (os.name == 'posix') +# +# Note: "fork" is not recommended on macOS and py38+. +# see https://bugs.python.org/issue33725 +parallel_available = (multiprocessing and + (os.name == 'posix') and + not (sys.version_info > (3, 8) and platform.system() == 'Darwin')) class SerialTasks: diff --git a/tests/test_util_logging.py b/tests/test_util_logging.py index cf4dc4d43..9e5ff7386 100644 --- a/tests/test_util_logging.py +++ b/tests/test_util_logging.py @@ -10,6 +10,8 @@ import codecs import os +import platform +import sys import pytest from docutils import nodes @@ -276,6 +278,8 @@ def test_colored_logs(app, status, warning): @pytest.mark.xfail(os.name != 'posix', reason="Not working on windows") +@pytest.mark.xfail(platform.system() == 'Darwin' and sys.version_info > (3, 8), + reason="Not working on macOS and py38") def test_logging_in_ParallelTasks(app, status, warning): logging.setup(app, status, warning) logger = logging.getLogger(__name__)