Prevent use on Python 3.12.5 (#4447)

Fixes #4446
See https://github.com/python/cpython/issues/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
This commit is contained in:
Shantanu 2024-09-07 16:41:06 -07:00 committed by GitHub
parent ac28187bf4
commit 9e13708be8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 21 additions and 7 deletions

View File

@ -26,7 +26,8 @@ jobs:
- name: Set up latest Python - name: Set up latest Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "*" python-version: "3.13"
allow-prereleases: true
- name: Install dependencies - name: Install dependencies
run: | run: |

View File

@ -22,7 +22,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: 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: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@ -26,7 +26,8 @@ jobs:
- name: Set up latest Python - name: Set up latest Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "*" python-version: "3.13"
allow-prereleases: true
- name: Install dependencies - name: Install dependencies
run: | run: |

View File

@ -23,7 +23,8 @@ jobs:
- name: Set up latest Python - name: Set up latest Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "*" python-version: "3.13"
allow-prereleases: true
- name: Install latest pip, build, twine - name: Install latest pip, build, twine
run: | run: |

View File

@ -31,7 +31,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: 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] os: [ubuntu-latest, macOS-latest, windows-latest]
steps: steps:
@ -99,7 +99,7 @@ jobs:
- name: Set up latest Python - name: Set up latest Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "*" python-version: "3.12.4"
- name: Install black with uvloop - name: Install black with uvloop
run: | run: |

View File

@ -34,7 +34,7 @@ jobs:
- name: Set up latest Python - name: Set up latest Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "*" python-version: "3.12.4"
- name: Install Black and PyInstaller - name: Install Black and PyInstaller
run: | run: |

View File

@ -7,6 +7,9 @@
<!-- Include any especially major or disruptive changes here --> <!-- Include any especially major or disruptive changes here -->
- Black now officially supports Python 3.13 (#4436) - 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 ### Stable style

View File

@ -549,6 +549,14 @@ def main( # noqa: C901
"""The uncompromising code formatter.""" """The uncompromising code formatter."""
ctx.ensure_object(dict) 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: if src and code is not None:
out( out(
main.get_usage(ctx) main.get_usage(ctx)