Skip to content

Commit

Permalink
Prevent use on Python 3.12.5
Browse files Browse the repository at this point in the history
Fixes psf#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 committed Sep 7, 2024
1 parent 7fa1faf commit 6757a75
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,13 @@ 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 6757a75

Please sign in to comment.