bpo-40421: Add PyFrame_GetCode() function (GH-19757)

PyFrame_GetCode(frame): return a borrowed reference to the frame
code.

Replace frame->f_code with PyFrame_GetCode(frame) in most code,
except in frameobject.c, genobject.c and ceval.c.

Also add PyFrame_GetLineNumber() to the limited C API.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index d0a15e7..92206c5 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -1222,3 +1222,10 @@
                            numfree, sizeof(PyFrameObject));
 }
 
+
+PyCodeObject *
+PyFrame_GetCode(PyFrameObject *frame)
+{
+    assert(frame != NULL);
+    return frame->f_code;
+}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index bf95dd6..9d97f38 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -8033,13 +8033,13 @@
         PyFrameObject *f;
         PyCodeObject *co;
         Py_ssize_t i, n;
-        f = _PyThreadState_GET()->frame;
+        f = PyThreadState_GetFrame(_PyThreadState_GET());
         if (f == NULL) {
             PyErr_SetString(PyExc_RuntimeError,
                             "super(): no current frame");
             return -1;
         }
-        co = f->f_code;
+        co = PyFrame_GetCode(f);
         if (co == NULL) {
             PyErr_SetString(PyExc_RuntimeError,
                             "super(): no code object");