]> granicus.if.org Git - python/commitdiff
Issue #24400: Remove inspect.isawaitable().
authorYury Selivanov <yselivanov@sprymix.com>
Tue, 30 Jun 2015 22:19:01 +0000 (18:19 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Tue, 30 Jun 2015 22:19:01 +0000 (18:19 -0400)
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).

Doc/library/inspect.rst
Doc/whatsnew/3.5.rst
Lib/inspect.py
Lib/test/test_inspect.py

index d4ebffd584570633c5de773178e17b467abbc410..8bce5223f8b65d3228701fb34d12f6a284760fda 100644 (file)
@@ -303,16 +303,6 @@ attributes:
    .. 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.
index abc1b8db6e26651cb51758d8549d2f9a6a9e06ab..63a5ff53d8e3cd48fb82e2de33b8931ddfd07b7e 100644 (file)
@@ -527,9 +527,8 @@ inspect
 * 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`.)
index 6285a6cdd5c85cbeb69e59613b6a8b6b7d1108d7..f48769e514473a5ccdc0ba1cbf1231f453fc4bb9 100644 (file)
@@ -186,10 +186,6 @@ def iscoroutinefunction(object):
     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.
 
index 39fa484abc591a2602080b043a273123e267cbf4..ebd106c1d7ab3b9d3400006617b00f570ed612cb 100644 (file)
@@ -159,31 +159,6 @@ class TestPredicates(IsTestBase):
 
         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))