Jump to solution
Verify

The Fix

pip install requests==2.27.0

Based on closed psf/requests issue #4986 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -189,5 +189,7 @@ Patches and Suggestions - Rajiv Mayani (`@mayani <https://github.com/mayani>`_) - Antti Kaihola (`@akaihola <https://github.com/akaihola>`_) +- "Dull Bananas" <[email protected]> (`@dullbananas <https://github.com/dullbananas>`_) +- Alessio Izzo (`@aless10 <https://github.com/aless10>`_) - Belavin Denis (`@luckydenis <https://github.com/luckydenis>`_)
repro.py
$ pytest --doctest-module . ============================= test session starts =============================== platform darwin -- Python 3.7.0, pytest-4.0.2, py-1.7.0, pluggy-0.8.1 rootdir: requests/requests, inifile: pytest.ini plugins: xdist-1.26.1, mock-1.10.1, httpbin-1.0.0, forked-1.0.2, cov-2.6.1 collected 11 items __init__.py . [ 9%] adapters.py . [ 18%] api.py . [ 27%] models.py .. [ 45%] sessions.py . [ 54%] status_codes.py . [ 63%] utils.py .... [100%] ==========================11 passed in 2.92 seconds=============================
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 requests==2.27.0\nWhen NOT to use: This fix is not applicable if the doctests are expected to handle different data types.\n\n

Why This Fix Works in Production

  • Trigger: Doctest fails (7 out of 11)
  • Mechanism: Doctests fail due to incorrect expected output for string comparisons in the requests library
  • Why the fix works: Fixes failing doctests in the requests library by correcting the expected output for string comparisons. (first fixed release: 2.27.0).

Why This Breaks in Prod

  • Shows up under Python 3.7.0 in real deployments (not just unit tests).
  • Doctests fail due to incorrect expected output for string comparisons in the requests library
  • Production symptom (often without a traceback): Doctest fails (7 out of 11)

Proof / Evidence

  • GitHub issue: #4986
  • Fix PR: https://github.com/psf/requests/pull/4987
  • First fixed release: 2.27.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-07
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.47

Discussion

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

“Hi! I noticed that the related PR was merged (https://github.com/psf/requests/pull/4987) but this issue is still open. Should we close it?”
@aless10 · 2020-03-20 · confirmation · source
“The PR looks good. Let's wait for the ci to go through.”
@timofurrer · 2019-02-17 · source

Failure Signature (Search String)

  • Doctest fails (7 out of 11)
  • =============================== FAILURES ===================================
Copy-friendly signature
signature.txt
Failure Signature ----------------- Doctest fails (7 out of 11) =============================== FAILURES ===================================

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Doctest fails (7 out of 11) =============================== FAILURES ===================================

Minimal Reproduction

repro.py
$ pytest --doctest-module . ============================= test session starts =============================== platform darwin -- Python 3.7.0, pytest-4.0.2, py-1.7.0, pluggy-0.8.1 rootdir: requests/requests, inifile: pytest.ini plugins: xdist-1.26.1, mock-1.10.1, httpbin-1.0.0, forked-1.0.2, cov-2.6.1 collected 11 items __init__.py . [ 9%] adapters.py . [ 18%] api.py . [ 27%] models.py .. [ 45%] sessions.py . [ 54%] status_codes.py . [ 63%] utils.py .... [100%] ==========================11 passed in 2.92 seconds=============================

Environment

  • Python: 3.7.0

What Broke

Doctests fail, leading to potential undetected issues in production code.

Why It Broke

Doctests fail due to incorrect expected output for string comparisons in the requests library

Fix Options (Details)

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

pip install requests==2.27.0

When NOT to use: This fix is not applicable if the doctests are expected to handle different data types.

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

Fix reference: https://github.com/psf/requests/pull/4987

First fixed release: 2.27.0

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

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if the doctests are expected to handle different data types.

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 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
2.27.0 Fixed

Related Issues

No related fixes found.

Sources

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