From 29a1f37a5517209d238012413eba4e5cfec3af34 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 3 Aug 2023 12:38:26 +0200 Subject: [PATCH] Fix missing HTTPConnection._set_hostport() in python 3.8 Fixes #1650 Python 3.8 introduces some breaking changes with regards to `HTTPConnection`'s internal structure. One of them is replacing former `_set_hostport()` method by `_get_hostport()` with slightly different usage. This commit therefore re-adds a `_set_hostport()` method to Package Control's `ValidatingHTTPSConnection` class in order to maintain compatibility with both ST3 (py 3.3) and ST4 (py 3.8). --- package_control/http/validating_https_connection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package_control/http/validating_https_connection.py b/package_control/http/validating_https_connection.py index af9e1e2d..d836fc1b 100644 --- a/package_control/http/validating_https_connection.py +++ b/package_control/http/validating_https_connection.py @@ -85,6 +85,14 @@ def validate_cert_host(self, cert, hostname): return True return False + # Compatibility for python 3.3 vs 3.8 + # python 3.8 replaced _set_hostport() by _get_hostport() + if not hasattr(DebuggableHTTPConnection, '_set_hostport'): + + def _set_hostport(self, host, port): + (self.host, self.port) = self._get_hostport(self.host, self.port) + self._validate_host(self.host) + def _tunnel(self): """ This custom _tunnel method allows us to read and print the debug