summaryrefslogtreecommitdiff
path: root/Lib/asyncio/test_utils.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-11-13 13:38:22 -0500
committerGitHub <noreply@github.com>2017-11-13 13:38:22 -0500
commitce12629c84400c52734859e43b2386deb2b6da12 (patch)
treecdb52f53c12fb119fa717071fd3ff18247432720 /Lib/asyncio/test_utils.py
parentf76231f89a7231fd486b37f728fbb4aab389e4d7 (diff)
downloadcpython-git-ce12629c84400c52734859e43b2386deb2b6da12.tar.gz
bpo-28369: Enhance transport socket check in add_reader/writer (#4365)
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: