[New-bugs-announce] [issue26437] asyncio create_server() not always accepts the 'port' parameter as str

Xavier de Gaye report at bugs.python.org
Thu Feb 25 08:51:59 EST 2016

New submission from Xavier de Gaye:

create_server() used to accept the 'port' parameter as a string before in all cases (until last december at least).
The following session shows the difference in behavior when the listening address is INADDR_ANY and '':

$ python
Python 3.6.0a0 (default:47fa003aa9f1, Feb 24 2016, 13:09:02) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from asyncio import *
>>> loop = get_event_loop()
>>> coro = loop.create_server(Protocol(), '', '12345')
>>> loop.run_until_complete(coro)
<Server sockets=[<socket.socket fd=7, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('', 12345)>, <socket.socket fd=9, family=AddressFamily.AF_INET6, type=2049, proto=6, laddr=('::', 12345, 0, 0)>]>
>>> coro = loop.create_server(Protocol(), '', '12345')
>>> loop.run_until_complete(coro)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 373, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 240, in _step
    result = coro.send(None)
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 946, in create_server
TypeError: an integer is required (got type str)

IMPHO python should consistently either accept 'port' as str or require 'port' as int.

components: Library (Lib)
messages: 260857
nosy: giampaolo.rodola, gvanrossum, haypo, pitrou, xdegaye, yselivanov
priority: normal
severity: normal
status: open
title: asyncio create_server() not always accepts the 'port' parameter as str
type: behavior
versions: Python 3.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list