diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-13 08:58:33 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-13 08:58:33 (GMT) |
commit | 38dc250521d2c34f58537b25301a0ac9a4bb6c85 (patch) | |
tree | 22510baff7fcfa37789fd564bf859b9cec3129ef /Lib/selectors.py | |
parent | d9fe22ce9b7d351193bef274eaad0e7b43cbb903 (diff) | |
download | cpython-38dc250521d2c34f58537b25301a0ac9a4bb6c85.zip cpython-38dc250521d2c34f58537b25301a0ac9a4bb6c85.tar.gz cpython-38dc250521d2c34f58537b25301a0ac9a4bb6c85.tar.bz2 |
Issue #23209, #23225: selectors.BaseSelector.close() now clears its internal
reference to the selector mapping to break a reference cycle. Initial patch
written by Martin Richard.
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r-- | Lib/selectors.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py index e4ad4cb..beb7ef7 100644 --- a/Lib/selectors.py +++ b/Lib/selectors.py @@ -175,6 +175,8 @@ class BaseSelector(metaclass=ABCMeta): """ mapping = self.get_map() try: + if mapping is None: + raise KeyError return mapping[fileobj] except KeyError: raise KeyError("{!r} is not registered".format(fileobj)) from None @@ -256,6 +258,7 @@ class _BaseSelectorImpl(BaseSelector): def close(self): self._fd_to_key.clear() + self._map = None def get_map(self): return self._map |