[3.7] bpo-33026: Fix jumping out of "with" block by setting f_lineno. (GH-6026). (#6074)

(cherry picked from commit 26c9f565d016db21257a60d29ab2c99383dd5ac7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 3083e5b..2825041 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -320,6 +320,13 @@
             PyObject *v = (*--f->f_stacktop);
             Py_DECREF(v);
         }
+        if (b->b_type == SETUP_FINALLY &&
+            code[b->b_handler] == WITH_CLEANUP_START)
+        {
+            /* Pop the exit function. */
+            PyObject *v = (*--f->f_stacktop);
+            Py_DECREF(v);
+        }
     }
 
     /* Finally set the new f_lineno and f_lasti and return OK. */