Skip to content

Commit 5d92e80

Browse files
committed
chore: exception on unsupported Python versions
1 parent 4356f1a commit 5d92e80

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project
66
adheres to [Semantic Versioning](https://semver.org/).
77

8+
## Unreleased
9+
10+
### :bug: Fixes
11+
12+
- Raise an exception at both build and runtime when using an unsupported Python version,
13+
instead of crashing with a segmentation fault at runtime (in the rare cases where
14+
`backports.zstd` was installed despite the `requires-python` marker)
15+
816
## [1.2.0] - 2025-12-06
917

1018
[1.2.0]: https://github.com/rogdham/backports.zstd/releases/tag/v1.2.0

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
from setuptools import Extension, setup
88

9+
if not ((3, 9) <= sys.version_info < (3, 14)):
10+
raise RuntimeError(f"Unsupported Python version: {sys.version}")
11+
12+
913
# create a LICENSE_zstd.txt file
1014
# wheels distributions needs to ship the license of the zstd library
1115
ROOT_PATH = Path(__file__).parent.absolute()

src/python/backports/zstd/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Python bindings to the Zstandard (zstd) compression library (RFC-8878)."""
22

3+
import sys
4+
if not ((3, 9) <= sys.version_info < (3, 14)):
5+
raise RuntimeError(f"Unsupported Python version: {sys.version}")
6+
37
__all__ = (
48
# backports.zstd
59
'COMPRESSION_LEVEL_DEFAULT',

0 commit comments

Comments
 (0)