The Fix
pip install stripe==14.4.0a2
Based on closed stripe/stripe-python issue #217 · 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%.
@@ -18,8 +18,11 @@ def add_params(self, params):
self._write(self.line_break)
if hasattr(value, 'read'):
- self._write("Content-Disposition: form-data; name=\"%s\"; "
- "filename=\"%s\"" % (key, value.name))
+ self._write("Content-Disposition: form-data; name=\"")
Option A — Upgrade to fixed release\npip install stripe==14.4.0a2\nWhen NOT to use: Do not apply this fix if the application requires strict encoding for text files.\n\n
Why This Fix Works in Production
- Trigger: Problem with uploading binary files with Python 3
- Mechanism: The file upload method incorrectly handles binary files in Python 3 due to encoding assumptions
- Why the fix works: Fixes the handling of ASCII/Unicode in file uploads for both Python 2 and 3, addressing the issue of binary file uploads failing. (first fixed release: 14.4.0a2).
- 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.5 in real deployments (not just unit tests).
- The file upload method incorrectly handles binary files in Python 3 due to encoding assumptions
- Surfaces as: Traceback (most recent call last):\n <snip>\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/site-packages/stripe/multipart_data_generator.py", line 28, in add_params\n…
Proof / Evidence
- GitHub issue: #217
- Fix PR: https://github.com/stripe/stripe-python/pull/218
- First fixed release: 14.4.0a2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.45
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Actually, while we're at it, we should also handle the case where Python 2 will have to deal with Unicode strings.”
“> @brandur, any thoughts? Should I proceed with the above? Yes! Looks very reasonable to me. We should also consider augmenting the test suite for…”
Failure Signature (Search String)
- Problem with uploading binary files with Python 3
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):\n <snip>\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/site-packages/stripe/multipart_data_generator.py", line 28, in add_params\n self._write_file(value)\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/site-packages/stripe/multipart_data_generator.py", line 54, in _write_file\n file_contents = f.read(self.chunk_size)\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/codecs.py", line 321, in decode\n (result, consumed) = self._buffer_decode(data, self.errors, final)
Stack trace
Error Message
-------------
Traceback (most recent call last):\n <snip>\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/site-packages/stripe/multipart_data_generator.py", line 28, in add_params\n self._write_file(value)\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/site-packages/stripe/multipart_data_generator.py", line 57, in _write_file\n self._write(file_contents)\n File "/Users/ob/.pyenv/versions/3.5.1/lib/python3.5/site-packages/stripe/multipart_data_generator.py", line 50, in _write\n self.data.write(bytes(value, 'utf-8'))
Environment
- Python: 3.5
What Broke
Uploading binary files fails, causing application errors and potential data loss.
Why It Broke
The file upload method incorrectly handles binary files in Python 3 due to encoding assumptions
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install stripe==14.4.0a2
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/stripe/stripe-python/pull/218
First fixed release: 14.4.0a2
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the application requires strict encoding for text files.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 14.4.0a2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.