aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 444042f82d9..93120071b40 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1776,9 +1776,17 @@ sys__getframe_impl(PyObject *module, int depth)
return NULL;
}
- while (depth > 0 && frame != NULL) {
- frame = frame->previous;
- --depth;
+ if (frame != NULL) {
+ while (depth > 0) {
+ frame = frame->previous;
+ if (frame == NULL) {
+ break;
+ }
+ if (_PyFrame_IsIncomplete(frame)) {
+ continue;
+ }
+ --depth;
+ }
}
if (frame == NULL) {
_PyErr_SetString(tstate, PyExc_ValueError,