Jump to solution
Verify

The Fix

pip install urllib3==1.25

Based on closed urllib3/urllib3 issue #839 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -40,7 +40,8 @@ packages=['urllib3', 'urllib3.packages', 'urllib3.packages.ssl_match_hostname', - 'urllib3.contrib', 'urllib3.util', + 'urllib3.packages.backports', 'urllib3.contrib', + 'urllib3.util',
repro.py
Traceback (most recent call last): File "/Users/davidf/Projects/webcrystal/venv/lib/python3.4/site-packages/urllib3/contrib/pyopenssl.py", line 60, in <module> from socket import _fileobject ImportError: cannot import name '_fileobject' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/davidf/Projects/webcrystal/venv/lib/python3.4/site-packages/urllib3/contrib/pyopenssl.py", line 63, in <module> from urllib3.packages.backports.makefile import backport_makefile ImportError: No module named 'urllib3.packages.backports'
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install urllib3==1.25\nWhen NOT to use: This fix should not be applied if the package structure is altered in future versions.\n\n

Why This Fix Works in Production

  • Trigger: from socket import _fileobject
  • Mechanism: The package was incorrectly configured, missing the backports module in the setup
  • Why the fix works: The issue was resolved by ensuring that backports are distributed correctly in the package setup. (first fixed release: 1.25).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.4.4 in real deployments (not just unit tests).
  • The package was incorrectly configured, missing the backports module in the setup
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #839
  • Fix PR: https://github.com/urllib3/urllib3/pull/841
  • First fixed release: 1.25
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.43

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Nope, that looks like a real bug to me! In particular, this looks like we incorrectly packaged the release”
@Lukasa · 2016-04-11 · source

Failure Signature (Search String)

  • from socket import _fileobject

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "/Users/davidf/Projects/webcrystal/venv/lib/python3.4/site-packages/urllib3/contrib/pyopenssl.py", line 60, in <module> from socket import _fileobject ImportError: cannot import name '_fileobject' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/davidf/Projects/webcrystal/venv/lib/python3.4/site-packages/urllib3/contrib/pyopenssl.py", line 63, in <module> from urllib3.packages.backports.makefile import backport_makefile ImportError: No module named 'urllib3.packages.backports'

Minimal Reproduction

repro.py
Traceback (most recent call last): File "/Users/davidf/Projects/webcrystal/venv/lib/python3.4/site-packages/urllib3/contrib/pyopenssl.py", line 60, in <module> from socket import _fileobject ImportError: cannot import name '_fileobject' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/davidf/Projects/webcrystal/venv/lib/python3.4/site-packages/urllib3/contrib/pyopenssl.py", line 63, in <module> from urllib3.packages.backports.makefile import backport_makefile ImportError: No module named 'urllib3.packages.backports'

Environment

  • Python: 3.4.4

Why It Broke

The package was incorrectly configured, missing the backports module in the setup

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install urllib3==1.25

When NOT to use: This fix should not be applied if the package structure is altered in future versions.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/urllib3/urllib3/pull/841

First fixed release: 1.25

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be applied if the package structure is altered in future versions.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
  • Upgrade behind a canary and run integration tests against the canary before 100% rollout.
  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

VersionStatus
1.25 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.