From 50ef6df82ecb7016be1af41768c2c6cfcf9c6e26 Mon Sep 17 00:00:00 2001 From: thearpankumar Date: Sat, 4 Oct 2025 10:08:39 +0530 Subject: [PATCH 1/7] ::CI-run From a60337ff27954bd333a8ae78bb34f9dbe24041f0 Mon Sep 17 00:00:00 2001 From: thearpankumar Date: Sat, 4 Oct 2025 10:26:56 +0530 Subject: [PATCH 2/7] fix1 --- cheroot/test/conftest.py | 17 +++++++++++++++++ pytest.ini | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/cheroot/test/conftest.py b/cheroot/test/conftest.py index 2e967b0572..23860c6ebe 100644 --- a/cheroot/test/conftest.py +++ b/cheroot/test/conftest.py @@ -4,6 +4,7 @@ itself, useless for end-users' app testing. """ +import sys import threading import time @@ -20,6 +21,22 @@ ) +# Python 3.14 compatibility: Force 'fork' multiprocessing start method +# Python 3.14 changed the default from 'fork' to 'forkserver' on Unix, +# which can cause issues with pytest-xdist's parallel test execution. +# This ensures compatibility with existing test fixtures and shared state. +# Ref: https://github.com/cherrypy/cheroot/issues/767 +if sys.version_info >= (3, 14): + try: + import multiprocessing + # Only set if not already set (avoid RuntimeError) + if multiprocessing.get_start_method(allow_none=True) is None: + multiprocessing.set_start_method('fork', force=True) + except (ImportError, RuntimeError): + # multiprocessing not available or start method already set + pass + + @pytest.fixture def http_request_timeout(): """Return a common HTTP request timeout for tests with queries.""" diff --git a/pytest.ini b/pytest.ini index 6586702144..f6b58bf8b2 100644 --- a/pytest.ini +++ b/pytest.ini @@ -62,6 +62,16 @@ filterwarnings = # Ref: https://github.com/cherrypy/cheroot/issues/734 ignore:Exception ignored in. Date: Sat, 4 Oct 2025 10:26:56 +0530 Subject: [PATCH 3/7] fix 1 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 02080670d1..58acca9888 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -191,7 +191,7 @@ repos: - flake8-pytest-style ~= 1.6.0 - flake8-spellcheck ~= 0.28.0 - wemake-python-styleguide ~= 1.1.0 - language_version: python3.11 # flake8-commas doesn't work w/ Python 3.12 + language_version: python3.14 # flake8-commas doesn't work w/ Python 3.12 - repo: https://github.com/Lucas-C/pre-commit-hooks-lxml.git rev: v1.1.0 From a6e4ca02b306e5d90698c9b054002ad26a5d11c2 Mon Sep 17 00:00:00 2001 From: thearpankumar Date: Sat, 4 Oct 2025 14:23:15 +0530 Subject: [PATCH 4/7] fix 3 --- .pre-commit-config.yaml | 2 +- cheroot/test/conftest.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 58acca9888..77baf62017 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -191,7 +191,7 @@ repos: - flake8-pytest-style ~= 1.6.0 - flake8-spellcheck ~= 0.28.0 - wemake-python-styleguide ~= 1.1.0 - language_version: python3.14 # flake8-commas doesn't work w/ Python 3.12 + language_version: python3.13 # Temp: flake8-annotations not Python 3.14 ready-commas doesn't work w/ Python 3.12 - repo: https://github.com/Lucas-C/pre-commit-hooks-lxml.git rev: v1.1.0 diff --git a/cheroot/test/conftest.py b/cheroot/test/conftest.py index 23860c6ebe..7326623b25 100644 --- a/cheroot/test/conftest.py +++ b/cheroot/test/conftest.py @@ -29,11 +29,11 @@ if sys.version_info >= (3, 14): try: import multiprocessing - # Only set if not already set (avoid RuntimeError) - if multiprocessing.get_start_method(allow_none=True) is None: - multiprocessing.set_start_method('fork', force=True) + + # Force fork method even if already set to forkserver + multiprocessing.set_start_method('fork', force=True) except (ImportError, RuntimeError): - # multiprocessing not available or start method already set + # multiprocessing not available or already set and force failed pass From 758a7621973c972742e4b7a8bb2519da903cd995 Mon Sep 17 00:00:00 2001 From: thearpankumar Date: Sat, 4 Oct 2025 16:41:26 +0530 Subject: [PATCH 5/7] fix: Update IOBase warning filter for Python 3.14 error message format Python 3.14 changed IOBase error message from 'Exception ignored in.' to 'Exception ignored while calling deallocator', breaking the existing regex filter. Updated to match both formats. Also reverted .pre-commit-config.yaml to python3.14 (CI doesn't have 3.13). --- .pre-commit-config.yaml | 3 ++- pytest.ini | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 77baf62017..c7dccf1ce3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -191,7 +191,8 @@ repos: - flake8-pytest-style ~= 1.6.0 - flake8-spellcheck ~= 0.28.0 - wemake-python-styleguide ~= 1.1.0 - language_version: python3.13 # Temp: flake8-annotations not Python 3.14 ready-commas doesn't work w/ Python 3.12 + # flake8-annotations not Python 3.14 ready yet + language_version: python3.14 - repo: https://github.com/Lucas-C/pre-commit-hooks-lxml.git rev: v1.1.0 diff --git a/pytest.ini b/pytest.ini index f6b58bf8b2..261cdc3560 100644 --- a/pytest.ini +++ b/pytest.ini @@ -60,7 +60,9 @@ filterwarnings = # FIXME: Python 3.13 no longer ignores IOBase errors raised by the close(), # FIXME: which exposed a possible race condition in test_conn test cleanup. # Ref: https://github.com/cherrypy/cheroot/issues/734 - ignore:Exception ignored in. Date: Sat, 4 Oct 2025 18:31:40 +0530 Subject: [PATCH 6/7] fix: Add Windows support to multiprocessing fix and update pre-commit config - Only force 'fork' on Unix (Windows doesn't support fork method) - Change flake8 language_version to python3.11 for CI compatibility - Fixes ValueError on Windows: 'cannot find context for fork' --- .pre-commit-config.yaml | 4 ++-- cheroot/test/conftest.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7dccf1ce3..a30d56c197 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -191,8 +191,8 @@ repos: - flake8-pytest-style ~= 1.6.0 - flake8-spellcheck ~= 0.28.0 - wemake-python-styleguide ~= 1.1.0 - # flake8-annotations not Python 3.14 ready yet - language_version: python3.14 + # Use Python 3.11 for CI compatibility (flake8-annotations not 3.14 ready) + language_version: python3.11 - repo: https://github.com/Lucas-C/pre-commit-hooks-lxml.git rev: v1.1.0 diff --git a/cheroot/test/conftest.py b/cheroot/test/conftest.py index 7326623b25..98eee55dcd 100644 --- a/cheroot/test/conftest.py +++ b/cheroot/test/conftest.py @@ -21,12 +21,13 @@ ) -# Python 3.14 compatibility: Force 'fork' multiprocessing start method -# Python 3.14 changed the default from 'fork' to 'forkserver' on Unix, +# Python 3.14 compatibility: Force 'fork' multiprocessing start method on Unix +# Python 3.14 changed the default from 'fork' to 'forkserver' on Unix platforms, # which can cause issues with pytest-xdist's parallel test execution. # This ensures compatibility with existing test fixtures and shared state. +# Note: Windows doesn't support 'fork', so we skip this on Windows. # Ref: https://github.com/cherrypy/cheroot/issues/767 -if sys.version_info >= (3, 14): +if sys.version_info >= (3, 14) and not IS_WINDOWS: try: import multiprocessing From 7ad50476308891057e29468454cfb45ca97d1486 Mon Sep 17 00:00:00 2001 From: thearpankumar Date: Sat, 4 Oct 2025 18:42:21 +0530 Subject: [PATCH 7/7] fix: Use contextlib.suppress and resolve linter violations - Replace try-except-pass with contextlib.suppress (ruff SIM105) - Shorten comment lines to meet 79 char limit (flake8 LN002) - Split nested try blocks to satisfy flake8 WPS229 - Remove unused WPS436 noqa comment --- cheroot/test/conftest.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cheroot/test/conftest.py b/cheroot/test/conftest.py index 98eee55dcd..5aec1e988d 100644 --- a/cheroot/test/conftest.py +++ b/cheroot/test/conftest.py @@ -4,13 +4,14 @@ itself, useless for end-users' app testing. """ +import contextlib import sys import threading import time import pytest -from .._compat import IS_MACOS, IS_WINDOWS # noqa: WPS436 +from .._compat import IS_MACOS, IS_WINDOWS from ..server import Gateway, HTTPServer from ..testing import ( # noqa: F401 # pylint: disable=unused-import get_server_client, @@ -21,21 +22,19 @@ ) -# Python 3.14 compatibility: Force 'fork' multiprocessing start method on Unix -# Python 3.14 changed the default from 'fork' to 'forkserver' on Unix platforms, +# Python 3.14 compatibility: Force 'fork' multiprocessing on Unix +# Python 3.14 changed default from 'fork' to 'forkserver' on Unix, # which can cause issues with pytest-xdist's parallel test execution. # This ensures compatibility with existing test fixtures and shared state. # Note: Windows doesn't support 'fork', so we skip this on Windows. # Ref: https://github.com/cherrypy/cheroot/issues/767 if sys.version_info >= (3, 14) and not IS_WINDOWS: - try: + with contextlib.suppress(ImportError): import multiprocessing - # Force fork method even if already set to forkserver - multiprocessing.set_start_method('fork', force=True) - except (ImportError, RuntimeError): - # multiprocessing not available or already set and force failed - pass + with contextlib.suppress(RuntimeError): + # Force fork method even if already set to forkserver + multiprocessing.set_start_method('fork', force=True) @pytest.fixture