Skip to content

[Feature request] Support connect to ipv6 address #1252

@Jarvan-Wang

Description

@Jarvan-Wang

debugpy works well with ipv4,
now I are trying to use ipv6 , and obtain :
Error: invalid --connect <address>: invalid port number

I tried to modify debugpy/server/cli.py to fix address parse error:

def set_address(mode):
    def do(arg, it):
        if options.address is not None:
            raise ValueError("--listen and --connect are mutually exclusive")

        # It's either host:port, or just port.
        value = next(it)
        def get_host_port(address):
            parts = address.split(":")
            host = ":".join(parts[:-1])
            if host == "": 
                host = "127.0.0.1"
            port = parts[-1]
            return host, port
        host, port = get_host_port(value)
        #host, sep, port = value.partition(":")
        #if not sep:
        #    host = "127.0.0.1"
        #    port = value
        try:
            port = int(port)
        except Exception:
            port = -1
        if not (0 <= port < 2 ** 16):
            raise ValueError("invalid port number")

        options.mode = mode
        options.address = (host, port)

    return do

rerun and obtain:

  File "debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 491, in start_client
    s.connect((host, port))
socket.gaierror: [Errno -9] Address family for hostname not supported

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in next releaseThis issue has been fixed, but won't be available to customers until the next release.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions