Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /