Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

getaddrinfo doesn't accept port service names #353

@1st1

Description

@1st1

socket.getaddrinfo and loop.getaddrinfo in Python 3.5.1 can accept service names for its port argument, i.e.

>>> socket.getaddrinfo('127.0.0.1', 'http')
[(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('127.0.0.1', 80)),
 (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 80))]

In 3.5.2 with our custom _ipaddr_info such calls will fail with an exception:

>>> import asyncio, socket
>>> loop = asyncio.get_event_loop()
>>> loop.run_until_complete(loop.getaddrinfo('127.0.0.1', 'http', type=socket.SOCK_STREAM))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yury/dev/py/asyncio/asyncio/base_events.py", line 589, in getaddrinfo
    info = _ipaddr_info(host, port, family, type, proto)
  File "/Users/yury/dev/py/asyncio/asyncio/base_events.py", line 108, in _ipaddr_info
    port = int(port)
ValueError: invalid literal for int() with base 10: 'http'

/cc @ajdavis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions