diff options
author | Yury Selivanov <yury@magic.io> | 2017-11-13 13:38:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 13:38:22 -0500 |
commit | ce12629c84400c52734859e43b2386deb2b6da12 (patch) | |
tree | cdb52f53c12fb119fa717071fd3ff18247432720 /Lib/asyncio/test_utils.py | |
parent | f76231f89a7231fd486b37f728fbb4aab389e4d7 (diff) | |
download | cpython-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.py | 7 |
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: |