mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-114887 Reject only sockets of type SOCK_STREAM in create_da… (#114980)
Also improve exception message.
(cherry picked from commit 94ec2b9c9c
)
Co-authored-by: Donghee Na <donghee.na92@gmail.com>
This commit is contained in:
parent
27cacdd5b4
commit
49fbb068d5
3 changed files with 5 additions and 3 deletions
|
@ -1315,9 +1315,9 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
allow_broadcast=None, sock=None):
|
||||
"""Create datagram connection."""
|
||||
if sock is not None:
|
||||
if sock.type != socket.SOCK_DGRAM:
|
||||
if sock.type == socket.SOCK_STREAM:
|
||||
raise ValueError(
|
||||
f'A UDP Socket was expected, got {sock!r}')
|
||||
f'A datagram socket was expected, got {sock!r}')
|
||||
if (local_addr or remote_addr or
|
||||
family or proto or flags or
|
||||
reuse_port or allow_broadcast):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue