Fix urllib3 +security version parsing in check_compatibility (2.27.1+security.3)#4
Merged
Merged
Conversation
urllib3's ActiveState build reports '1.26.20+security.2'; splitting on '.' yielded ['1','26','20+security','2'], breaking the major/minor/patch unpack and int(patch). Drop the '+security.N' (PEP 440 local) segment before splitting. Python 2 compatible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes requests.check_compatibility() to correctly handle urllib3 versions that include a PEP 440 local-version segment (e.g. 1.26.20+security.2), preventing import-time failures when such builds are installed.
Changes:
- Strip any
+<local>segment fromurllib3_versionbefore splitting/parsing incheck_compatibility(). - Bump Requests version to
2.27.1+security.3. - Document the bugfix in
HISTORY.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| requests/init.py | Removes PEP 440 local version suffix before parsing urllib3.__version__, avoiding unpack/int conversion failures. |
| requests/version.py | Bumps library version to 2.27.1+security.3. |
| HISTORY.md | Adds a release note describing the compatibility parsing fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
emanuelc-activestate
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
check_compatibility()for urllib3's+securityversionOur urllib3 AS build now reports a PEP 440 local version,
1.26.20+security.2.requests.check_compatibility()did:'1.26.20+security.2'.split('.')→['1', '26', '20+security', '2'](4 elements), which breaks the 3-way unpack and theint('20+security')conversion — so importingrequestsraises.Fix
Strip the
+localsegment before splitting:'1.26.20+security.2'→'1.26.20'→['1','26','20']. One line, Python 2 compatible (juststr.split/slice/int), and it preserves the existing['dev']guard and the16.1→16.1.0two-component case.Verification (Python 2.7)
1.26.20+security.2→(1, 26, 20)(asserts pass);1.26.20,1.26.0,1.21.1,1.26parse as before;devstill rejected. Changed files byte-compile on 2.7.Bundled as release 2.27.1+security.3 (
__version__bumped, HISTORY.md entry; tag stays 4-component2.27.1.3per convention).🤖 Generated with Claude Code