[Python-checkins] cpython (3.5): Issue #24400: Remove inspect.isawaitable().

yury.selivanov python-checkins at python.org
Wed Jul 1 00:19:31 CEST 2015


https://hg.python.org/cpython/rev/e20c197f19d6
changeset:   96728:e20c197f19d6
branch:      3.5
parent:      96726:73c7d29a8c10
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Tue Jun 30 18:19:01 2015 -0400
summary:
  Issue #24400: Remove inspect.isawaitable().

isawaitable() was added before collections.abc.Awaitable; now,
with Awaitable, it is no longer needed (we don't have ishashable()
or isiterable() methods in the inspect module either).

files:
  Doc/library/inspect.rst  |  10 ----------
  Doc/whatsnew/3.5.rst     |   5 ++---
  Lib/inspect.py           |   4 ----
  Lib/test/test_inspect.py |  25 -------------------------
  4 files changed, 2 insertions(+), 42 deletions(-)


diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -303,16 +303,6 @@
    .. versionadded:: 3.5
 
 
-.. function:: isawaitable(object)
-
-   Return true if the object can be used in :keyword:`await`
-   expression.
-
-   See also :class:`collections.abc.Awaitable`.
-
-   .. versionadded:: 3.5
-
-
 .. function:: istraceback(object)
 
    Return true if the object is a traceback.
diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -527,9 +527,8 @@
 * New argument ``follow_wrapped`` for :func:`inspect.signature`.
   (Contributed by Yury Selivanov in :issue:`20691`.)
 
-* New :func:`~inspect.iscoroutine`, :func:`~inspect.iscoroutinefunction`,
-  and :func:`~inspect.isawaitable` functions.  (Contributed by Yury Selivanov
-  in :issue:`24017`.)
+* New :func:`~inspect.iscoroutine` and :func:`~inspect.iscoroutinefunction`
+  functions.  (Contributed by Yury Selivanov in :issue:`24017`.)
 
 * New :func:`~inspect.getcoroutinelocals` and :func:`~inspect.getcoroutinestate`
   functions.  (Contributed by Yury Selivanov in :issue:`24400`.)
diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -186,10 +186,6 @@
     return bool((isfunction(object) or ismethod(object)) and
                 object.__code__.co_flags & CO_COROUTINE)
 
-def isawaitable(object):
-    """Return true if the object can be used in "await" expression."""
-    return isinstance(object, collections.abc.Awaitable)
-
 def isgenerator(object):
     """Return true if the object is a generator.
 
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -159,31 +159,6 @@
 
         coro.close(); gen_coro.close() # silence warnings
 
-    def test_isawaitable(self):
-        def gen(): yield
-        self.assertFalse(inspect.isawaitable(gen()))
-
-        coro = coroutine_function_example(1)
-        gen_coro = gen_coroutine_function_example(1)
-
-        self.assertTrue(
-            inspect.isawaitable(coro))
-        self.assertTrue(
-            inspect.isawaitable(gen_coro))
-
-        class Future:
-            def __await__():
-                pass
-        self.assertTrue(inspect.isawaitable(Future()))
-        self.assertFalse(inspect.isawaitable(Future))
-
-        class NotFuture: pass
-        not_fut = NotFuture()
-        not_fut.__await__ = lambda: None
-        self.assertFalse(inspect.isawaitable(not_fut))
-
-        coro.close(); gen_coro.close() # silence warnings
-
     def test_isroutine(self):
         self.assertTrue(inspect.isroutine(mod.spam))
         self.assertTrue(inspect.isroutine([].count))

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list