-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File Uploading with Python 3.6.2 #377
Comments
I've looked at #217 but there doesn't appear to be anything pertinent to this issue in there although the titles suggest otherwise. |
If I comment out lines 119 and 120 in utils.py uploading works for Python 3.6.2: 119 # if six.PY3 and hasattr(val, 'decode'):
120 # val = val.decode('utf-8') |
Hey @jkeyes, thanks for the report! If I understand correctly, there are two different issues here:
|
Okay, so it appears that we're logging the encoded stripe-python/stripe/api_requestor.py Lines 334 to 335 in f948b8b
This works fine for regular x-www-form-urlencoded requests, but not so well for multipart-form requests. I think we ought to log the params before encoding. It's what we do in the Ruby library: https://github.com/stripe/stripe-ruby/blob/d41a59fc82cd9989b16ebad9a4bcd9e39395466e/lib/stripe/stripe_client.rb#L443-L446. Files would simply be represented by their usual Python |
Yeah, that makes a lot more sense. Nobody is going to want the encoded file contents in their logs anyway |
PR #378 created. Without the change to |
Python Version: 3.6.2
Stripe: 1.75.1
The snippet from the Python docs for uploading a file is not working for me:
raises a UnicodeDecodeError:
Opening the file in
rb
mode also fails:The code is working under Python 2.7.13. I really feel like I must be overlooking something here, but I've tried various means with no success. Any ideas?
The text was updated successfully, but these errors were encountered: