Skip to content

Commit

Permalink
Prevent use on Python 3.12.5 (#4447)
Browse files Browse the repository at this point in the history
Fixes #4446
See python/cpython#123821

It's possible this is too strict? We could instead do this anytime the
AST safety check fails, but feels weird to have that happen
non-deterministically
  • Loading branch information
hauntsaninja authored Sep 7, 2024
1 parent ac28187 commit 9e13708
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pypi_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<!-- Include any especially major or disruptive changes here -->

- 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

Expand Down
8 changes: 8 additions & 0 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9e13708

Please sign in to comment.