From 68afa1977b2541aaac9086e00e4fe681a168b8b2 Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Tue, 9 Dec 2025 09:26:17 +0100 Subject: [PATCH 1/4] feat(python): urllib3 version 2.6 compatibility --- .../templates/python/README_onlypackage.mustache | 2 +- openapi-generator/templates/python/api_client.mustache | 6 +++--- openapi-generator/templates/python/exceptions.mustache | 2 +- .../python/python-experimental/README_onlypackage.mustache | 2 +- .../python/python-experimental/api_client.mustache | 6 +++--- .../python/python-experimental/requirements.mustache | 2 +- .../templates/python/python-experimental/setup.mustache | 2 +- openapi-generator/templates/python/requirements.mustache | 2 +- openapi-generator/templates/python/rest.mustache | 6 +++--- openapi-generator/templates/python/setup.mustache | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openapi-generator/templates/python/README_onlypackage.mustache b/openapi-generator/templates/python/README_onlypackage.mustache index 149360d07..18b198d93 100644 --- a/openapi-generator/templates/python/README_onlypackage.mustache +++ b/openapi-generator/templates/python/README_onlypackage.mustache @@ -24,7 +24,7 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: -* urllib3 >= 1.15, < 2.6 +* urllib3 >= 1.15 * six >= 1.10 * certifi * python-dateutil diff --git a/openapi-generator/templates/python/api_client.mustache b/openapi-generator/templates/python/api_client.mustache index 89eab7fa8..ce676809a 100644 --- a/openapi-generator/templates/python/api_client.mustache +++ b/openapi-generator/templates/python/api_client.mustache @@ -209,14 +209,14 @@ class ApiClient(object): return (return_data) else: return (return_data, response_data.status, - response_data.getheaders()) + response_data.headers) {{/tornado}} {{#tornado}} if _return_http_data_only: raise tornado.gen.Return(return_data) else: raise tornado.gen.Return((return_data, response_data.status, - response_data.getheaders())) + response_data.headers)) {{/tornado}} def sanitize_for_serialization(self, obj): @@ -588,7 +588,7 @@ class ApiClient(object): os.close(fd) os.remove(path) - content_disposition = response.getheader("Content-Disposition") + content_disposition = response.headers.get("Content-Disposition") if content_disposition: filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1) diff --git a/openapi-generator/templates/python/exceptions.mustache b/openapi-generator/templates/python/exceptions.mustache index dd012f34a..5e1d808c3 100644 --- a/openapi-generator/templates/python/exceptions.mustache +++ b/openapi-generator/templates/python/exceptions.mustache @@ -80,7 +80,7 @@ class ApiException(OpenApiException): self.status = http_resp.status self.reason = http_resp.reason self.body = http_resp.data - self.headers = http_resp.getheaders() + self.headers = http_resp.headers else: self.status = status self.reason = reason diff --git a/openapi-generator/templates/python/python-experimental/README_onlypackage.mustache b/openapi-generator/templates/python/python-experimental/README_onlypackage.mustache index 37aa1eb83..11c002c9a 100644 --- a/openapi-generator/templates/python/python-experimental/README_onlypackage.mustache +++ b/openapi-generator/templates/python/python-experimental/README_onlypackage.mustache @@ -25,7 +25,7 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: -* urllib3 >= 1.15, < 2.6 +* urllib3 >= 1.15 * six >= 1.10 * certifi * python-dateutil diff --git a/openapi-generator/templates/python/python-experimental/api_client.mustache b/openapi-generator/templates/python/python-experimental/api_client.mustache index 774dae89c..25066dd7e 100644 --- a/openapi-generator/templates/python/python-experimental/api_client.mustache +++ b/openapi-generator/templates/python/python-experimental/api_client.mustache @@ -202,14 +202,14 @@ class ApiClient(object): return (return_data) else: return (return_data, response_data.status, - response_data.getheaders()) + response_data.headers) {{/tornado}} {{#tornado}} if _return_http_data_only: raise tornado.gen.Return(return_data) else: raise tornado.gen.Return((return_data, response_data.status, - response_data.getheaders())) + response_data.headers)) {{/tornado}} def sanitize_for_serialization(self, obj): @@ -274,7 +274,7 @@ class ApiClient(object): # handle file downloading # save response body into a tmp file and return the instance if response_type == (file_type,): - content_disposition = response.getheader("Content-Disposition") + content_disposition = response.headers.get("Content-Disposition") return deserialize_file(response.data, self.configuration, content_disposition=content_disposition) diff --git a/openapi-generator/templates/python/python-experimental/requirements.mustache b/openapi-generator/templates/python/python-experimental/requirements.mustache index 3b219f8ce..a56bedffb 100644 --- a/openapi-generator/templates/python/python-experimental/requirements.mustache +++ b/openapi-generator/templates/python/python-experimental/requirements.mustache @@ -4,4 +4,4 @@ future; python_version<="2.7" six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.15.1, < 2.6 +urllib3 >= 1.15.1 diff --git a/openapi-generator/templates/python/python-experimental/setup.mustache b/openapi-generator/templates/python/python-experimental/setup.mustache index d6b586867..c1df4717e 100644 --- a/openapi-generator/templates/python/python-experimental/setup.mustache +++ b/openapi-generator/templates/python/python-experimental/setup.mustache @@ -17,7 +17,7 @@ VERSION = "{{packageVersion}}" # http://pypi.python.org/pypi/setuptools REQUIRES = [ - "urllib3>=1.15,<2.6", + "urllib3>=1.15", "six >= 1.10", "certifi", "python-dateutil", diff --git a/openapi-generator/templates/python/requirements.mustache b/openapi-generator/templates/python/requirements.mustache index 86611d576..eb358efd5 100644 --- a/openapi-generator/templates/python/requirements.mustache +++ b/openapi-generator/templates/python/requirements.mustache @@ -3,4 +3,4 @@ future; python_version<="2.7" six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.15.1, < 2.6 +urllib3 >= 1.15.1 diff --git a/openapi-generator/templates/python/rest.mustache b/openapi-generator/templates/python/rest.mustache index 418d8f268..29e224565 100644 --- a/openapi-generator/templates/python/rest.mustache +++ b/openapi-generator/templates/python/rest.mustache @@ -32,16 +32,16 @@ class RESTResponse(io.IOBase): def getheaders(self): """Returns a dictionary of the response headers.""" - return self.urllib3_response.getheaders() + return self.urllib3_response.headers def getheader(self, name, default=None): """Returns a given response header.""" - return self.urllib3_response.getheader(name, default) + return self.urllib3_response.headers.get(name, default) def getencoding(self): """Returns charset encoding returned by the server.""" encoding = 'utf-8' - content_type = self.getheader('Content-Type') + content_type = self.headers.get('Content-Type') if content_type: m = re.search(r'charset=(\S+)', content_type) if m: encoding = m.group(1) diff --git a/openapi-generator/templates/python/setup.mustache b/openapi-generator/templates/python/setup.mustache index 9fc8bec83..ce774eafb 100644 --- a/openapi-generator/templates/python/setup.mustache +++ b/openapi-generator/templates/python/setup.mustache @@ -16,7 +16,7 @@ VERSION = "{{packageVersion}}" # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3>=1.15,<2.6", "six >= 1.10", "certifi", "python-dateutil"] +REQUIRES = ["urllib3>=1.15", "six >= 1.10", "certifi", "python-dateutil"] {{#asyncio}} REQUIRES.append("aiohttp >= 3.0.0") {{/asyncio}} From c3fec537b94637a9f8e201f800b3cb96a674850d Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Tue, 9 Dec 2025 09:43:48 +0100 Subject: [PATCH 2/4] fix --- openapi-generator/templates/python/rest.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi-generator/templates/python/rest.mustache b/openapi-generator/templates/python/rest.mustache index 29e224565..51795af63 100644 --- a/openapi-generator/templates/python/rest.mustache +++ b/openapi-generator/templates/python/rest.mustache @@ -41,7 +41,7 @@ class RESTResponse(io.IOBase): def getencoding(self): """Returns charset encoding returned by the server.""" encoding = 'utf-8' - content_type = self.headers.get('Content-Type') + content_type = self.getheader('Content-Type') if content_type: m = re.search(r'charset=(\S+)', content_type) if m: encoding = m.group(1) From 87a495b189dd73307f7afcad042300154c971775 Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Tue, 9 Dec 2025 09:52:54 +0100 Subject: [PATCH 3/4] adapt python specs --- clients/python/test/test_locales_api.py | 4 ++-- clients/python/test/test_uploads_api.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/python/test/test_locales_api.py b/clients/python/test/test_locales_api.py index d6371c8b8..a898e8048 100644 --- a/clients/python/test/test_locales_api.py +++ b/clients/python/test/test_locales_api.py @@ -15,7 +15,7 @@ import sys if sys.version_info[:2] <= (3, 7): - from mock import Mock, patch + from mock import Mock, patch else: from unittest.mock import Mock, patch @@ -71,7 +71,7 @@ def test_locale_download(self, mock_get): mock_get.return_value.data = body mock_get.return_value.status = 200 mock_get.return_value.getencoding.return_value = 'utf-8' - mock_get.return_value.getheader.side_effect = { 'Content-Disposition': None }.get + mock_get.return_value.headers = { 'Content-Disposition': None } with phrase_api.ApiClient(self.configuration) as api_client: api_instance = phrase_api.api.locales_api.LocalesApi(api_client) diff --git a/clients/python/test/test_uploads_api.py b/clients/python/test/test_uploads_api.py index 8eb11627f..6b0678cd9 100644 --- a/clients/python/test/test_uploads_api.py +++ b/clients/python/test/test_uploads_api.py @@ -44,7 +44,7 @@ def test_upload_create(self, mock_post): mock_post.return_value.data = '{"id": "upload_id", "format": "csv"}'.encode() mock_post.return_value.getencoding.return_value = 'utf-8' mock_post.return_value.status = 201 - mock_post.return_value.getheader.side_effect = { 'Content-Type': "application/json" }.get + mock_post.return_value.headers = { 'Content-Type': "application/json" } project_id = "project_id_example" with phrase_api.ApiClient(self.configuration) as api_client: From 8eaedf23eed92cd9055a79e8969abee23e6f0988 Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Tue, 9 Dec 2025 09:55:30 +0100 Subject: [PATCH 4/4] fix --- openapi-generator/templates/python/api_client.mustache | 2 +- .../templates/python/python-experimental/api_client.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi-generator/templates/python/api_client.mustache b/openapi-generator/templates/python/api_client.mustache index ce676809a..f5394e88f 100644 --- a/openapi-generator/templates/python/api_client.mustache +++ b/openapi-generator/templates/python/api_client.mustache @@ -588,7 +588,7 @@ class ApiClient(object): os.close(fd) os.remove(path) - content_disposition = response.headers.get("Content-Disposition") + content_disposition = response.getheader("Content-Disposition") if content_disposition: filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1) diff --git a/openapi-generator/templates/python/python-experimental/api_client.mustache b/openapi-generator/templates/python/python-experimental/api_client.mustache index 25066dd7e..9a47a50fa 100644 --- a/openapi-generator/templates/python/python-experimental/api_client.mustache +++ b/openapi-generator/templates/python/python-experimental/api_client.mustache @@ -274,7 +274,7 @@ class ApiClient(object): # handle file downloading # save response body into a tmp file and return the instance if response_type == (file_type,): - content_disposition = response.headers.get("Content-Disposition") + content_disposition = response.getheader("Content-Disposition") return deserialize_file(response.data, self.configuration, content_disposition=content_disposition)