From dfbef43743aa8a3f7e32d0ea785c2ece4a96d0ea Mon Sep 17 00:00:00 2001 From: shwetas1205 Date: Fri, 2 Feb 2018 20:30:04 +0530 Subject: [PATCH] Fixed unicode error and supported allow_nonstandard_methods in tornado 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 --- .../src/main/resources/python/api_client.mustache | 2 +- .../src/main/resources/python/tornado/rest.mustache | 2 +- .../petstore-security-test/python/petstore_api/api_client.py | 2 +- .../client/petstore/python-asyncio/petstore_api/api_client.py | 2 +- .../client/petstore/python-tornado/petstore_api/api_client.py | 2 +- samples/client/petstore/python/petstore_api/api_client.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 6a9a1c2744cc..a6df41b072a5 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/python/tornado/rest.mustache b/modules/swagger-codegen/src/main/resources/python/tornado/rest.mustache index 90593fc98a9f..5f96ed97b20b 100644 --- a/modules/swagger-codegen/src/main/resources/python/tornado/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/tornado/rest.mustache @@ -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 diff --git a/samples/client/petstore-security-test/python/petstore_api/api_client.py b/samples/client/petstore-security-test/python/petstore_api/api_client.py index 360016c25655..7d7849d63c6b 100644 --- a/samples/client/petstore-security-test/python/petstore_api/api_client.py +++ b/samples/client/petstore-security-test/python/petstore_api/api_client.py @@ -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 diff --git a/samples/client/petstore/python-asyncio/petstore_api/api_client.py b/samples/client/petstore/python-asyncio/petstore_api/api_client.py index 6029e8fa113f..0a362e400390 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api_client.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api_client.py @@ -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 diff --git a/samples/client/petstore/python-tornado/petstore_api/api_client.py b/samples/client/petstore/python-tornado/petstore_api/api_client.py index 222812fdb738..52d5e8aa0817 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api_client.py +++ b/samples/client/petstore/python-tornado/petstore_api/api_client.py @@ -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 diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index ec4e3cd5c425..28f65e75fcfc 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -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