Skip to content

Commit 9e13708

Browse files
authored
Prevent use on Python 3.12.5 (#4447)
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
1 parent ac28187 commit 9e13708

File tree

8 files changed

+21
-7
lines changed

8 files changed

+21
-7
lines changed

.github/workflows/doc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
- name: Set up latest Python
2727
uses: actions/setup-python@v5
2828
with:
29-
python-version: "*"
29+
python-version: "3.13"
30+
allow-prereleases: true
3031

3132
- name: Install dependencies
3233
run: |

.github/workflows/fuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
25+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.4", "3.13"]
2626

2727
steps:
2828
- uses: actions/checkout@v4

.github/workflows/lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
- name: Set up latest Python
2727
uses: actions/setup-python@v5
2828
with:
29-
python-version: "*"
29+
python-version: "3.13"
30+
allow-prereleases: true
3031

3132
- name: Install dependencies
3233
run: |

.github/workflows/pypi_upload.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
- name: Set up latest Python
2424
uses: actions/setup-python@v5
2525
with:
26-
python-version: "*"
26+
python-version: "3.13"
27+
allow-prereleases: true
2728

2829
- name: Install latest pip, build, twine
2930
run: |

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9"]
34+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.4", "3.13", "pypy-3.9"]
3535
os: [ubuntu-latest, macOS-latest, windows-latest]
3636

3737
steps:
@@ -99,7 +99,7 @@ jobs:
9999
- name: Set up latest Python
100100
uses: actions/setup-python@v5
101101
with:
102-
python-version: "*"
102+
python-version: "3.12.4"
103103

104104
- name: Install black with uvloop
105105
run: |

.github/workflows/upload_binary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Set up latest Python
3535
uses: actions/setup-python@v5
3636
with:
37-
python-version: "*"
37+
python-version: "3.12.4"
3838

3939
- name: Install Black and PyInstaller
4040
run: |

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<!-- Include any especially major or disruptive changes here -->
88

99
- Black now officially supports Python 3.13 (#4436)
10+
- Black will issue an error when used with Python 3.12.5, due to an upstream memory
11+
safety issue in Python 3.12.5 that can cause Black's AST safety checks to fail. Please
12+
use Python 3.12.6 or Python 3.12.4 instead. (#4447)
1013

1114
### Stable style
1215

src/black/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,14 @@ def main( # noqa: C901
549549
"""The uncompromising code formatter."""
550550
ctx.ensure_object(dict)
551551

552+
if sys.version_info[:3] == (3, 12, 5):
553+
out(
554+
"Python 3.12.5 has a memory safety issue that can cause Black's "
555+
"AST safety checks to fail. "
556+
"Please upgrade to Python 3.12.6 or downgrade to Python 3.12.4"
557+
)
558+
ctx.exit(1)
559+
552560
if src and code is not None:
553561
out(
554562
main.get_usage(ctx)

0 commit comments

Comments
 (0)