Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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)
repro.py
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")
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 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).
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 2.33.2 in real deployments (not just unit tests).
  • Surfaces as: TypeError: quote_from_bytes() expected bytes

Proof / Evidence

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)).”
@ob-stripe · 2019-08-06 · confirmation · source
“@NicolaGenesin Charge.capture expects a charge ID, not a full charge object. This should work:”
@ob-stripe · 2019-08-02 · source
“@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)”
@NicolaGenesin · 2019-08-02 · source
“@ob-stripe that's helpful. Thank you for your explanation (now it makes sense to me as well)”
@NicolaGenesin · 2019-08-02 · source

Failure Signature (Search String)

  • TypeError: quote_from_bytes() expected bytes

Error Message

Stack trace
error.txt
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

repro.py
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

When NOT to use: This fix should not be used if the application relies on the new class method behavior exclusively.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

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

  • 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

VersionStatus
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.