mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-45129 Remove deprecated reuse_address (GH-28207)
Due to significant security concerns, the reuse_address parameter of asyncio.loop.create_datagram_endpoint, deprecated in Python 3.9, is now removed. This is because of the behavior of the socket option SO_REUSEADDR in UDP. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
a561005761
commit
59ea704df7
5 changed files with 33 additions and 70 deletions
|
@ -1794,32 +1794,6 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
|
|||
self.loop.run_until_complete(protocol.done)
|
||||
self.assertEqual('CLOSED', protocol.state)
|
||||
|
||||
def test_create_datagram_endpoint_reuse_address_error(self):
|
||||
# bpo-37228: Ensure that explicit passing of `reuse_address=True`
|
||||
# raises an error, as it is not safe to use SO_REUSEADDR when using UDP
|
||||
|
||||
coro = self.loop.create_datagram_endpoint(
|
||||
lambda: MyDatagramProto(create_future=True, loop=self.loop),
|
||||
local_addr=('127.0.0.1', 0),
|
||||
reuse_address=True)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(coro)
|
||||
|
||||
def test_create_datagram_endpoint_reuse_address_warning(self):
|
||||
# bpo-37228: Deprecate *reuse_address* parameter
|
||||
|
||||
coro = self.loop.create_datagram_endpoint(
|
||||
lambda: MyDatagramProto(create_future=True, loop=self.loop),
|
||||
local_addr=('127.0.0.1', 0),
|
||||
reuse_address=False)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
transport, protocol = self.loop.run_until_complete(coro)
|
||||
transport.close()
|
||||
self.loop.run_until_complete(protocol.done)
|
||||
self.assertEqual('CLOSED', protocol.state)
|
||||
|
||||
@patch_socket
|
||||
def test_create_datagram_endpoint_nosoreuseport(self, m_socket):
|
||||
del m_socket.SO_REUSEPORT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue