Skip to content

Commit 350a230

Browse files
authored
fix: support CPython 3.11.0-3.11.4 and older PyPy3.11 (#1055)
1 parent f0b6f1a commit 350a230

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Changelog
44
*unreleased*
55
~~~~~~~~~~~~
66

7-
No unreleased changes.
7+
Fixes:
8+
9+
* Support CPython 3.11.0-3.11.4 and older PyPy3.11 (:pull:`1055`)
810

911
26.0rc2 - 2026-01-12
1012
~~~~~~~~~~~~~~~~~~~~

src/packaging/version.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,15 @@ def __ne__(self, other: object) -> bool:
176176

177177
_VERSION_PATTERN_OLD = _VERSION_PATTERN.replace("*+", "*").replace("?+", "?")
178178

179+
# Possessive qualifiers were added in Python 3.11.
180+
# CPython 3.11.0-3.11.4 had a bug: https://github.com/python/cpython/pull/107795
181+
# Older PyPy also had a bug.
179182
VERSION_PATTERN = (
180-
_VERSION_PATTERN_OLD if sys.version_info < (3, 11) else _VERSION_PATTERN
183+
_VERSION_PATTERN_OLD
184+
if (sys.implementation.name == "cpython" and sys.version_info < (3, 11, 5))
185+
or (sys.implementation.name == "pypy" and sys.version_info < (3, 11, 13))
186+
or sys.version_info < (3, 11)
187+
else _VERSION_PATTERN
181188
)
182189
"""
183190
A string containing the regular expression used to match a valid version.

0 commit comments

Comments
 (0)