From: Victor Stinner Date: Tue, 13 Jan 2015 09:00:55 +0000 (+0100) Subject: Issue #23209, #23225: selectors.BaseSelector.get_key() now raises a X-Git-Tag: v3.5.0a1~191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=458fc6f98ca9a838af5dcdff64fd48ae3eb64fa9;p=python Issue #23209, #23225: selectors.BaseSelector.get_key() now raises a RuntimeError if the selector is closed. And selectors.BaseSelector.close() now clears its internal reference to the selector mapping to break a reference cycle. Initial patch written by Martin Richard. --- 458fc6f98ca9a838af5dcdff64fd48ae3eb64fa9 diff --cc Lib/selectors.py index 598845d43b,beb7ef7741..6d569c30ad --- a/Lib/selectors.py +++ b/Lib/selectors.py @@@ -174,7 -174,9 +174,9 @@@ class BaseSelector(metaclass=ABCMeta) SelectorKey for this file object """ mapping = self.get_map() ++ if mapping is None: ++ raise RuntimeError('Selector is closed') try: - if mapping is None: - raise KeyError return mapping[fileobj] except KeyError: raise KeyError("{!r} is not registered".format(fileobj)) from None diff --cc Lib/test/test_selectors.py index 493a5a6d50,dd30d441e6..15f71c1183 --- a/Lib/test/test_selectors.py +++ b/Lib/test/test_selectors.py @@@ -184,8 -187,10 +185,10 @@@ class BaseSelectorTestCase(unittest.Tes s.register(wr, selectors.EVENT_WRITE) s.close() -- self.assertRaises(KeyError, s.get_key, rd) -- self.assertRaises(KeyError, s.get_key, wr) ++ self.assertRaises(RuntimeError, s.get_key, rd) ++ self.assertRaises(RuntimeError, s.get_key, wr) + self.assertRaises(KeyError, mapping.__getitem__, rd) + self.assertRaises(KeyError, mapping.__getitem__, wr) def test_get_key(self): s = self.SELECTOR() @@@ -252,8 -257,8 +255,8 @@@ sel.register(rd, selectors.EVENT_READ) sel.register(wr, selectors.EVENT_WRITE) -- self.assertRaises(KeyError, s.get_key, rd) -- self.assertRaises(KeyError, s.get_key, wr) ++ self.assertRaises(RuntimeError, s.get_key, rd) ++ self.assertRaises(RuntimeError, s.get_key, wr) def test_fileno(self): s = self.SELECTOR() diff --cc Misc/NEWS index ec2e74a792,96e34e496c..04eb5a7aa7 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -203,24 -44,26 +203,29 @@@ Core and Builtin Library ------- -- 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. ++- Issue #23209, #23225: selectors.BaseSelector.get_key() now raises a ++ RuntimeError if the selector is closed. And selectors.BaseSelector.close() ++ now clears its internal reference to the selector mapping to break a ++ reference cycle. Initial patch written by Martin Richard. + -- Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The - availability of the function is checked during the compilation. Patch written - by Bernard Spil. +- Issue #19777: Provide a home() classmethod on Path objects. Contributed + by Victor Salgado and Mayank Tripathi. -- Issue #20896, #22935: The :func:`ssl.get_server_certificate` function now - uses the :data:`~ssl.PROTOCOL_SSLv23` protocol by default, not - :data:`~ssl.PROTOCOL_SSLv3`, for maximum compatibility and support platforms - where :data:`~ssl.PROTOCOL_SSLv3` support is disabled. +- Issue #23206: Make ``json.dumps(..., ensure_ascii=False)`` as fast as the + default case of ``ensure_ascii=True``. Patch by Naoki Inada. -- Issue #23111: In the ftplib, make ssl.PROTOCOL_SSLv23 the default protocol - version. +- Issue #23185: Add math.inf and math.nan constants. -- Issue #23132: Mitigate regression in speed and clarity in functools.total_ordering. +- Issue #23186: Add ssl.SSLObject.shared_ciphers() and + ssl.SSLSocket.shared_ciphers() to fetch the client's list ciphers sent at + handshake. -- Issue #22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(), - instead of reading /dev/urandom, to get pseudo-random bytes. +- Issue #23143: Remove compatibility with OpenSSLs older than 0.9.8. + +- Issue #23132: Improve performance and introspection support of comparison + methods created by functool.total_ordering. + +- Issue #19776: Add a expanduser() method on Path objects. - Issue #23112: Fix SimpleHTTPServer to correctly carry the query string and fragment when it redirects to add a trailing slash.