Skip to content

Commit 5b496e9

Browse files
committed
inspect: Implement iscoroutinefunction and iscoroutine.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 2665047 commit 5b496e9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

python-stdlib/inspect/inspect.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def isgenerator(obj):
2525
return isinstance(obj, type((_g)()))
2626

2727

28+
# In MicroPython there's currently no way to distinguish between generators and coroutines.
29+
iscoroutinefunction = isgeneratorfunction
30+
iscoroutine = isgenerator
31+
32+
2833
class _Class:
2934
def meth():
3035
pass

python-stdlib/inspect/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.2")
1+
metadata(version="0.1.3")
22

33
module("inspect.py")

python-stdlib/inspect/test_inspect.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ def test_isgeneratorfunction(self):
4444
def test_isgenerator(self):
4545
self._test_is_helper(inspect.isgenerator, entities[2])
4646

47+
def test_iscoroutinefunction(self):
48+
self._test_is_helper(inspect.iscoroutinefunction, entities[1])
49+
50+
def test_iscoroutine(self):
51+
self._test_is_helper(inspect.iscoroutine, entities[2])
52+
4753
def test_ismethod(self):
4854
self._test_is_helper(inspect.ismethod, entities[5])
4955

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy