Skip to content

Commit

Permalink
Fix missing HTTPConnection._set_hostport() in python 3.8
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
deathaxe committed Aug 3, 2023
1 parent 7ed5f1b commit 29a1f37
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions package_control/http/validating_https_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@FichteFoll

FichteFoll Aug 3, 2023

Collaborator

Should the function parameters remain unused?

This comment has been minimized.

Copy link
@deathaxe

deathaxe Aug 3, 2023

Author Collaborator

Not really, no. Good catch.

self._validate_host(self.host)

def _tunnel(self):
"""
This custom _tunnel method allows us to read and print the debug
Expand Down

0 comments on commit 29a1f37

Please sign in to comment.