

def _set_hostport(self, host, port):
    if (port is None):
        i = host.rfind(':')
        j = host.rfind(']')
        if (port > j):
            try:
                port = int(host[(i + 1):])
            except ValueError:
                if (host[(i + 1):] == ''):
                    port = self.default_port
                else:
                    raise InvalidURL(("nonnumeric port: '%s'" % host[(i + 1):]))
            host = host[:i]
        else:
            port = self.default_port
        if (host and (host[0] == '[') and (host[(- 1)] == ']')):
            host = host[1:(- 1)]
    self.host = host
    self.port = port

dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/future/backports/http/client.py HTTPConnection._set_hostport/VarMisuse@43/48 `i`->`port`