summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-01-20 11:46:39 (GMT)
committerGitHub <noreply@github.com>2022-01-20 11:46:39 (GMT)
commitb04dfbbe4bd7071d46c8688c2263726ea31d33cd (patch)
tree17989daaffa384df343b53289845fba667e20acc /Lib/inspect.py
parentd05a66339b5e07d72d96e4c30a34cc3821bb61a2 (diff)
downloadcpython-b04dfbbe4bd7071d46c8688c2263726ea31d33cd.zip
cpython-b04dfbbe4bd7071d46c8688c2263726ea31d33cd.tar.gz
cpython-b04dfbbe4bd7071d46c8688c2263726ea31d33cd.tar.bz2
bpo-46409: Make generators in bytecode (GH-30633)
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes. * Trim frame and generator by word each. * Minor refactor of frame.c * Update test.test_sys to account for smaller frames. * Treat generator functions as normal functions when evaluating and specializing.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 8236698..7a8f5d3 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1819,11 +1819,11 @@ def getgeneratorstate(generator):
"""
if generator.gi_running:
return GEN_RUNNING
+ if generator.gi_suspended:
+ return GEN_SUSPENDED
if generator.gi_frame is None:
return GEN_CLOSED
- if generator.gi_frame.f_lasti == -1:
- return GEN_CREATED
- return GEN_SUSPENDED
+ return GEN_CREATED
def getgeneratorlocals(generator):
@@ -1861,11 +1861,11 @@ def getcoroutinestate(coroutine):
"""
if coroutine.cr_running:
return CORO_RUNNING
+ if coroutine.cr_suspended:
+ return CORO_SUSPENDED
if coroutine.cr_frame is None:
return CORO_CLOSED
- if coroutine.cr_frame.f_lasti == -1:
- return CORO_CREATED
- return CORO_SUSPENDED
+ return CORO_CREATED
def getcoroutinelocals(coroutine):