diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 4c592d73919..901d4357298 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -26,7 +26,8 @@ jobs: - name: Set up latest Python uses: actions/setup-python@v5 with: - python-version: "*" + python-version: "3.13" + allow-prereleases: true - name: Install dependencies run: | diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index b3ea595c318..9d5f308e4e8 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.4", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f75734400ce..2d14092481a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -26,7 +26,8 @@ jobs: - name: Set up latest Python uses: actions/setup-python@v5 with: - python-version: "*" + python-version: "3.13" + allow-prereleases: true - name: Install dependencies run: | diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index 7b363d88528..ca548ecdd65 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -23,7 +23,8 @@ jobs: - name: Set up latest Python uses: actions/setup-python@v5 with: - python-version: "*" + python-version: "3.13" + allow-prereleases: true - name: Install latest pip, build, twine run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 036208799fa..5c8eb35ff1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.4", "3.13", "pypy-3.9"] os: [ubuntu-latest, macOS-latest, windows-latest] steps: @@ -99,7 +99,7 @@ jobs: - name: Set up latest Python uses: actions/setup-python@v5 with: - python-version: "*" + python-version: "3.12.4" - name: Install black with uvloop run: | diff --git a/.github/workflows/upload_binary.yml b/.github/workflows/upload_binary.yml index 06e55cfe93a..1bde446442a 100644 --- a/.github/workflows/upload_binary.yml +++ b/.github/workflows/upload_binary.yml @@ -34,7 +34,7 @@ jobs: - name: Set up latest Python uses: actions/setup-python@v5 with: - python-version: "*" + python-version: "3.12.4" - name: Install Black and PyInstaller run: | diff --git a/CHANGES.md b/CHANGES.md index a83a4df0023..988c36eeaa9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,9 @@ - Black now officially supports Python 3.13 (#4436) +- Black will issue an error when used with Python 3.12.5, due to an upstream memory + safety issue in Python 3.12.5 that can cause Black's AST safety checks to fail. Please + use Python 3.12.6 or Python 3.12.4 instead. (#4447) ### Stable style diff --git a/src/black/__init__.py b/src/black/__init__.py index 942f3160751..7822e3d1c36 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -549,6 +549,14 @@ def main( # noqa: C901 """The uncompromising code formatter.""" ctx.ensure_object(dict) + if sys.version_info[:3] == (3, 12, 5): + out( + "Python 3.12.5 has a memory safety issue that can cause Black's " + "AST safety checks to fail. " + "Please upgrade to Python 3.12.6 or downgrade to Python 3.12.4" + ) + ctx.exit(1) + if src and code is not None: out( main.get_usage(ctx)