Skip to content
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

Fix uploading files with Unicode names (Python 2.7) #636

Merged
merged 1 commit into from Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion stripe/multipart_data_generator.py
Expand Up @@ -29,7 +29,7 @@ def add_params(self, params):
# Convert the filename to string, just in case it's not
# already one. E.g. `tempfile.TemporaryFile` has a `name`
# attribute but it's an `int`.
filename = str(value.name)
filename = stripe.six.text_type(value.name)

self._write('Content-Disposition: form-data; name="')
self._write(key)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_multipart_data_generator.py
Expand Up @@ -86,3 +86,8 @@ def test_multipart_data_file_binary(self):
def test_multipart_data_stringio(self):
string = six.StringIO("foo")
self.run_test_multipart_data_with_file(string)

def test_multipart_data_unicode_file_name(self):
string = six.StringIO("foo")
string.name = u"паспорт.png"
self.run_test_multipart_data_with_file(string)