cheroot icon indicating copy to clipboard operation
cheroot copied to clipboard

Fix Python 3.14 compatiblity

Open thearpankumar opened this issue 4 months ago β€’ 0 comments

❓ What kind of change does this PR introduce?

  • [x] 🐞 bug fix
  • [ ] 🐣 feature
  • [ ] πŸ“‹ docs update
  • [ ] πŸ“‹ tests/coverage improvement
  • [ ] πŸ“‹ refactoring
  • [ ] πŸ’₯ other

πŸ“‹ What is the related issue number (starting with #)

Resolves #767

❓ What is the current behavior? (You can also link to an open issue here)

Python 3.14 tests fail in CI with:

  • Multiprocessing errors due to default start method change from fork to forkserver on Unix
  • IOBase cleanup errors during test teardown due to changed error message format
  • Pre-commit failures from flake8-annotations incompatibility

❓ What is the new behavior (if this is a feature change)?

All tests pass on Python 3.14 (Linux and Windows) with full backward compatibility for Python 3.8-3.13.

πŸ“‹ Other information:

Root Cause: Python 3.14 changed the default multiprocessing start method from fork to forkserver on Unix platforms, breaking pytest-xdist parallel test execution.

Solution Applied:

  1. Multiprocessing Fix (cheroot/test/conftest.py):

    • Force fork method on Python 3.14+ Unix systems only
    • Skip on Windows (doesn't support fork)
    • Clean exception handling with contextlib.suppress
  2. IOBase Warning Filter (pytest.ini):

    • Updated regex pattern to match Python 3.14's new error format
    • Changed from "Exception ignored in." to "Exception ignored.*"
  3. Pre-commit Config (.pre-commit-config.yaml):

    • Set flake8 language_version: python3.11 to match CI
    • Prevents flake8-annotations Python 3.14 incompatibility

Testing: Verified on Python 3.14.0rc3 with pytest-xdist parallel execution (n=auto).

πŸ“‹ Contribution checklist:

  • [x] I wrote descriptive pull request text above
  • [x] I think the code is well written
  • [x] I wrote good commit messages
  • [ ] I have squashed related commits together after the changes have been approved
  • [x] Unit tests for the changes exist
  • [x] Integration tests for the changes exist (if applicable)
  • [x] I used the same coding conventions as the rest of the project
  • [x] The new code doesn't generate linter offenses
  • [x] Documentation reflects the changes
  • [x] The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences

This change is Reviewable

thearpankumar avatar Oct 06 '25 12:10 thearpankumar