The Fix
pip install stripe==14.4.0a2
Based on closed stripe/stripe-python issue #597 · 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%.
@@ -213,12 +213,20 @@ def __call__(self, method):
return self
- def __get__(self, obj=None, objtype=None):
+ def __get__(self, obj, objtype=None):
@functools.wraps(self.method)
TypeError: quote_from_bytes() expected bytes
File "celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "booking/tasks/booking/sales/request.py", line 144, in run
status, error, processing_amount = self.capture_payment(sale)
File "booking/tasks/booking/sales/request.py", line 66, in capture_payment
result_charge = stripe.Charge.capture(charge)
File "stripe/util.py", line 223, in _wrapper
return class_method(*args, **kwargs)
File "stripe/api_resources/abstract/custom_method.py", line 20, in custom_method_request
quote_plus(util.utf8(sid)),
File "urllib/parse.py", line 805, in quote_plus
string = quote(string, safe + space, encoding, errors)
File "urllib/parse.py", line 789, in quote
return quote_from_bytes(string, safe)
File "urllib/parse.py", line 814, in quote_from_bytes
raise TypeError("quote_from_bytes() expected bytes")
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install stripe==14.4.0a2\nWhen NOT to use: This fix should not be used if the application relies on the new class method behavior exclusively.\n\n
Why This Fix Works in Production
- Trigger: TypeError: quote_from_bytes() expected bytes
- Mechanism: Restores support for passing full objects instead of IDs to custom methods in the Stripe Python library, fixing the TypeError encountered after upgrading from version 1.51.0 to 2.3.3.
- Why the fix works: Restores support for passing full objects instead of IDs to custom methods in the Stripe Python library, fixing the TypeError encountered after upgrading from version 1.51.0 to 2.3.3. (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 2.33.2 in real deployments (not just unit tests).
- Surfaces as: TypeError: quote_from_bytes() expected bytes
Proof / Evidence
- GitHub issue: #597
- Fix PR: https://github.com/stripe/stripe-python/pull/601
- First fixed release: 14.4.0a2
- 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.31
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“We just released stripe-python 2.33.2 which should restore support for the syntax you were using (stripe.Charge.capture(charge)).”
“@NicolaGenesin Charge.capture expects a charge ID, not a full charge object. This should work:”
“@ob-stripe thank you for quick response, I confirm you this works. Wondering why you dropped support for stripe.Charge.capture(charge) (working for 1.51.0)”
“@ob-stripe that's helpful. Thank you for your explanation (now it makes sense to me as well)”
Failure Signature (Search String)
- TypeError: quote_from_bytes() expected bytes
Error Message
Stack trace
Error Message
-------------
TypeError: quote_from_bytes() expected bytes
File "celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "booking/tasks/booking/sales/request.py", line 144, in run
status, error, processing_amount = self.capture_payment(sale)
File "booking/tasks/booking/sales/request.py", line 66, in capture_payment
result_charge = stripe.Charge.capture(charge)
File "stripe/util.py", line 223, in _wrapper
return class_method(*args, **kwargs)
File "stripe/api_resources/abstract/custom_method.py", line 20, in custom_method_request
quote_plus(util.utf8(sid)),
File "urllib/parse.py", line 805, in quote_plus
string = quote(string, safe + space, encoding, errors)
File "urllib/parse.py", line 789, in quote
return quote_from_bytes(string, safe)
File "urllib/parse.py", line 814, in quote_from_bytes
raise TypeError("quote_from_bytes() expected bytes")
Minimal Reproduction
TypeError: quote_from_bytes() expected bytes
File "celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "booking/tasks/booking/sales/request.py", line 144, in run
status, error, processing_amount = self.capture_payment(sale)
File "booking/tasks/booking/sales/request.py", line 66, in capture_payment
result_charge = stripe.Charge.capture(charge)
File "stripe/util.py", line 223, in _wrapper
return class_method(*args, **kwargs)
File "stripe/api_resources/abstract/custom_method.py", line 20, in custom_method_request
quote_plus(util.utf8(sid)),
File "urllib/parse.py", line 805, in quote_plus
string = quote(string, safe + space, encoding, errors)
File "urllib/parse.py", line 789, in quote
return quote_from_bytes(string, safe)
File "urllib/parse.py", line 814, in quote_from_bytes
raise TypeError("quote_from_bytes() expected bytes")
Environment
- Python: 2.33.2
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/601
First fixed release: 14.4.0a2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application relies on the new class method behavior exclusively.
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
- 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.