Skip to content

Commit

Permalink
Fixed unicode error and supported allow_nonstandard_methods in tornad…
Browse files Browse the repository at this point in the history
…o based python client (#7560)

* fixing "decoding Unicode is not supported" error for py2 when data is unicode

* allowing nonstandard methods for tornado python client.

* Making sure to return unicode when needed
  • Loading branch information
shwetas1205 authored and wing328 committed Feb 2, 2018
1 parent ea27924 commit dfbef43
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class ApiClient(object):
try:
return klass(data)
except UnicodeEncodeError:
return six.u(data)
return six.text_type(data)
except TypeError:
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RESTClientObject(object):
"body parameter cannot be used with post_params parameter."
)

request = httpclient.HTTPRequest(url)
request = httpclient.HTTPRequest(url, allow_nonstandard_methods=True)
request.ca_certs = self.ca_certs
request.client_key = self.client_key
request.client_cert = self.client_cert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def __deserialize_primitive(self, data, klass):
try:
return klass(data)
except UnicodeEncodeError:
return six.u(data)
return six.text_type(data)
except TypeError:
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def __deserialize_primitive(self, data, klass):
try:
return klass(data)
except UnicodeEncodeError:
return six.u(data)
return six.text_type(data)
except TypeError:
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def __deserialize_primitive(self, data, klass):
try:
return klass(data)
except UnicodeEncodeError:
return six.u(data)
return six.text_type(data)
except TypeError:
return data

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/python/petstore_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def __deserialize_primitive(self, data, klass):
try:
return klass(data)
except UnicodeEncodeError:
return six.u(data)
return six.text_type(data)
except TypeError:
return data

Expand Down

0 comments on commit dfbef43

Please sign in to comment.