|
96 | 96 |
|
97 | 97 | COOKIE_NAME = "vmware_soap_session" |
98 | 98 |
|
| 99 | +# Address gh-100985, fixed in Python 3.11.9 and 3.12.4 |
| 100 | +def _gh100985(addr): |
| 101 | + if addr and addr[0] == '[' and addr[-1] == ']': |
| 102 | + return addr[1:-1] |
| 103 | + else: |
| 104 | + return addr |
| 105 | + |
99 | 106 | # MethodFault type |
100 | 107 | MethodFault = GetVmodlType("vmodl.MethodFault") |
101 | 108 | # Localized MethodFault type |
@@ -1538,20 +1545,19 @@ def GetConnection(self): |
1538 | 1545 |
|
1539 | 1546 | # Python fails if both host:port pair |
1540 | 1547 | # and port are used for HTTPConnection |
1541 | | - host = getattr(self, 'httpProxyHost', self.host.rsplit(":", 1)[0]) |
1542 | | - port = getattr(self, 'httpProxyPort', self.port) |
1543 | | - |
1544 | | - # Fix for gh-100985 which is fixed |
1545 | | - # in Python 3.11.9 and Python 3.12.4 |
1546 | | - if host and host[0] == '[' and host[-1] == ']': |
1547 | | - host = host[1:-1] |
| 1548 | + host = self.host.rsplit(":", 1)[0] |
| 1549 | + port = self.port |
| 1550 | + conn_host = getattr(self, 'httpProxyHost', host) |
| 1551 | + conn_port = getattr(self, 'httpProxyPort', port) |
| 1552 | + conn_host = _gh100985(conn_host) |
1548 | 1553 |
|
1549 | | - conn = self.scheme(host=host, port=port, **self.schemeArgs) |
| 1554 | + conn = self.scheme(host=conn_host, port=conn_port, **self.schemeArgs) |
1550 | 1555 | if self.is_tunnel: |
1551 | 1556 | if hasattr(self, 'sslProxyPath'): |
1552 | 1557 | conn.setVcTunnel(self.sslProxyPath) |
1553 | 1558 | elif hasattr(self, 'httpProxyHost'): |
1554 | 1559 | customHeaders = self._customHeaders if self._customHeaders else {} |
| 1560 | + host = _gh100985(host) |
1555 | 1561 | conn.set_tunnel(host, port, customHeaders) |
1556 | 1562 | _Connect(connection=conn, serverPemCert=self.serverPemCert, thumbprint=self.thumbprint) |
1557 | 1563 |
|
|
0 commit comments