From ce12629c84400c52734859e43b2386deb2b6da12 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Mon, 13 Nov 2017 13:38:22 -0500 Subject: bpo-28369: Enhance transport socket check in add_reader/writer (#4365) --- Lib/asyncio/test_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/asyncio/test_utils.py') diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py index 65805947fd..c9b19825f2 100644 --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -361,6 +361,13 @@ class TestLoop(base_events.BaseEventLoop): handle._args, args) def _ensure_fd_no_transport(self, fd): + if not isinstance(fd, int): + try: + fd = int(fd.fileno()) + except (AttributeError, TypeError, ValueError): + # This code matches selectors._fileobj_to_fd function. + raise ValueError("Invalid file object: " + "{!r}".format(fd)) from None try: transport = self._transports[fd] except KeyError: -- cgit v1.2.1