The Fix
pip install urllib3==1.25
Based on closed urllib3/urllib3 issue #822 · 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%.
@@ -192,6 +192,7 @@ In chronological order:
* Jesse Shapiro <[email protected]>
* Working on encoding unicode header parameter names
+ * Making setup.py resilient to ASCII locales
* [Your name or handle] <[email or website]>
# (Install Docker from: http://www.docker.com )
# If OS X, start with:
$ docker-machine start default; eval "$(docker-machine env default)"
# If OS X or Linux, continue with:
$ docker run -it ubuntu:trusty # Ubuntu 14.04 LTS
$$ apt-get update
$$ apt-get install git -y
$$ apt-get install python3-pip -y
$$ pip3 install virtualenv
$$ git clone https://github.com/shazow/urllib3
$$ cd urllib3/
$$ virtualenv venv
$$ source venv/bin/activate
$$ make test
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==1.25\nWhen NOT to use: This fix is not suitable for environments where ASCII-only files are guaranteed.\n\n
Why This Fix Works in Production
- Trigger: python setup.py develop
- Mechanism: Fixes the setup.py to support ASCII locales by using codecs to read files with UTF-8 encoding.
- Why the fix works: Fixes the setup.py to support ASCII locales by using codecs to read files with UTF-8 encoding. (first fixed release: 1.25).
- 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 in real deployments (not just unit tests).
- Surfaces as: python setup.py develop
Proof / Evidence
- GitHub issue: #822
- Fix PR: https://github.com/urllib3/urllib3/pull/823
- 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.41
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Likely fix that works on Python 2 and 3: io.open('README.rst', encoding='utf8')”
“Oh you support Python 2.6 too. Here's a more-compatible version: codecs.open('README.rst', encoding='utf8')”
“Hm strange, can't reproduce the error on Python 3.5. Does changing it to u'\n\n' help at all?”
“This is _almost certainly_ a locale problem”
Failure Signature (Search String)
- python setup.py develop
Error Message
Stack trace
Error Message
-------------
python setup.py develop
Traceback (most recent call last):
File "setup.py", line 23, in <module>
long_description=open('README.rst').read() + '\n\n' + open('CHANGES.rst').read(),
File "/urllib3/venv/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 4597: ordinal not in range(128)
make: *** [*.egg-info] Error 1
Minimal Reproduction
# (Install Docker from: http://www.docker.com )
# If OS X, start with:
$ docker-machine start default; eval "$(docker-machine env default)"
# If OS X or Linux, continue with:
$ docker run -it ubuntu:trusty # Ubuntu 14.04 LTS
$$ apt-get update
$$ apt-get install git -y
$$ apt-get install python3-pip -y
$$ pip3 install virtualenv
$$ git clone https://github.com/shazow/urllib3
$$ cd urllib3/
$$ virtualenv venv
$$ source venv/bin/activate
$$ make test
Environment
- Python: 3.4
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==1.25
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/823
First fixed release: 1.25
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable for environments where ASCII-only files are guaranteed.
Verify Fix
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 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.