summaryrefslogtreecommitdiff
path: root/Lib/asyncio/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/test_utils.py')
-rw-r--r--Lib/asyncio/test_utils.py7
1 files changed, 7 insertions, 0 deletions
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: