Skip to content

Commit 15fd020

Browse files
committed
inspect: Support generators/async functions in inspect.signature.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 3eaf027 commit 15fd020

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

python-stdlib/inspect/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def signature(f):
111111
elif t is type(setattr):
112112
# A three-parameter built-in.
113113
num_args = 3
114-
elif t is type(signature):
114+
elif t is type(signature) or t is type(_g):
115115
# A bytecode function, work out the number of arguments by inspecting the bytecode data.
116116
fun_obj = uctypes.struct(id(f), (uctypes.ARRAY | 0, uctypes.LONG | 4))
117117
bytecode = uctypes.bytearray_at(fun_obj[3], 8)

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.2.0")
1+
metadata(version="0.2.1")
22

33
module("inspect.py")

python-stdlib/inspect/test_inspect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ def test_signature(self):
7171
self.assertEqual(len(inspect.signature(lambda x, y: 0).parameters), 2)
7272
self.assertEqual(len(inspect.signature(lambda x, y, z: 0).parameters), 3)
7373
self.assertEqual(len(inspect.signature(lambda x, y, *, z: 0).parameters), 3)
74+
self.assertEqual(len(inspect.signature(gen).parameters), 0)

0 commit comments

Comments
 (0)