summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-11-13 18:38:22 (GMT)
committerGitHub <noreply@github.com>2017-11-13 18:38:22 (GMT)
commitce12629c84400c52734859e43b2386deb2b6da12 (patch)
treecdb52f53c12fb119fa717071fd3ff18247432720 /Lib/asyncio/selector_events.py
parentf76231f89a7231fd486b37f728fbb4aab389e4d7 (diff)
downloadcpython-ce12629c84400c52734859e43b2386deb2b6da12.zip
cpython-ce12629c84400c52734859e43b2386deb2b6da12.tar.gz
cpython-ce12629c84400c52734859e43b2386deb2b6da12.tar.bz2
bpo-28369: Enhance transport socket check in add_reader/writer (#4365)
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 7143ca2..00d9a7e 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -246,8 +246,16 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
self.call_exception_handler(context)
def _ensure_fd_no_transport(self, fd):
+ fileno = fd
+ if not isinstance(fileno, int):
+ try:
+ fileno = int(fileno.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]
+ transport = self._transports[fileno]
except KeyError:
pass
else: