Skip to content

Fix urllib3 +security version parsing in check_compatibility (2.27.1+security.3)#4

Merged
icanhasmath merged 2 commits into
2.27.1.xfrom
fix-urllib3-security-version-parse
Jun 12, 2026
Merged

Fix urllib3 +security version parsing in check_compatibility (2.27.1+security.3)#4
icanhasmath merged 2 commits into
2.27.1.xfrom
fix-urllib3-security-version-parse

Conversation

@icanhasmath

Copy link
Copy Markdown

Fix check_compatibility() for urllib3's +security version

Our urllib3 AS build now reports a PEP 440 local version, 1.26.20+security.2. requests.check_compatibility() did:

urllib3_version = urllib3_version.split('.')
...
major, minor, patch = urllib3_version
major, minor, patch = int(major), int(minor), int(patch)

'1.26.20+security.2'.split('.')['1', '26', '20+security', '2'] (4 elements), which breaks the 3-way unpack and the int('20+security') conversion — so importing requests raises.

Fix

Strip the +local segment before splitting:

urllib3_version = urllib3_version.split('+', 1)[0].split('.')

'1.26.20+security.2''1.26.20'['1','26','20']. One line, Python 2 compatible (just str.split/slice/int), and it preserves the existing ['dev'] guard and the 16.116.1.0 two-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.26 parse as before; dev still rejected. Changed files byte-compile on 2.7.

Bundled as release 2.27.1+security.3 (__version__ bumped, HISTORY.md entry; tag stays 4-component 2.27.1.3 per convention).

🤖 Generated with Claude Code

icanhasmath and others added 2 commits June 12, 2026 08:24
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from urllib3_version before splitting/parsing in check_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.

@icanhasmath icanhasmath merged commit 76a1a70 into 2.27.1.x Jun 12, 2026
1 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants