]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45431: Rename CFrame to _PyCFrame in the C API (GH-31584)
authorVictor Stinner <vstinner@python.org>
Mon, 28 Feb 2022 15:03:57 +0000 (16:03 +0100)
committerGitHub <noreply@github.com>
Mon, 28 Feb 2022 15:03:57 +0000 (16:03 +0100)
Rename also struct _cframe to struct _PyCFrame.

Add a comment suggesting using public functions rather than using
directly the private _PyCFrame structure.

Include/cpython/pystate.h
Include/internal/pycore_frame.h
Python/ceval.c

index 0d38604636b2b64b67fe82fa49f6a4d9c0e2dad2..26d6f7576e524f8d24e34579638fb55ef8a9130b 100644 (file)
@@ -33,7 +33,9 @@ typedef struct {
     PyCodeAddressRange bounds; // Only valid if code != NULL.
 } PyTraceInfo;
 
-typedef struct _cframe {
+// Internal structure: you should not use it directly, but use public functions
+// like PyThreadState_EnterTracing() and PyThreadState_LeaveTracing().
+typedef struct _PyCFrame {
     /* This struct will be threaded through the C stack
      * allowing fast access to per-thread state that needs
      * to be accessed quickly by the interpreter, but can
@@ -47,8 +49,8 @@ typedef struct _cframe {
     int use_tracing;
     /* Pointer to the currently executing frame (it can be NULL) */
     struct _PyInterpreterFrame *current_frame;
-    struct _cframe *previous;
-} CFrame;
+    struct _PyCFrame *previous;
+} _PyCFrame;
 
 typedef struct _err_stackitem {
     /* This struct represents a single execution context where we might
@@ -102,9 +104,9 @@ struct _ts {
        the trace/profile. */
     int tracing;
 
-    /* Pointer to current CFrame in the C stack frame of the currently,
+    /* Pointer to current _PyCFrame in the C stack frame of the currently,
      * or most recently, executing _PyEval_EvalFrameDefault. */
-    CFrame *cframe;
+    _PyCFrame *cframe;
 
     Py_tracefunc c_profilefunc;
     Py_tracefunc c_tracefunc;
@@ -196,7 +198,7 @@ struct _ts {
     _PyErr_StackItem exc_state;
 
     /* The bottom-most frame on the stack. */
-    CFrame root_cframe;
+    _PyCFrame root_cframe;
 };
 
 
index 20e81b7849b202f1b8f4d9033d026b8f7c6b00c8..207983dcc22d7c981ac9f1ff31f9b563bfd0f2d9 100644 (file)
@@ -59,7 +59,7 @@ typedef struct _PyInterpreterFrame {
     int f_lasti;       /* Last instruction if called */
     int stacktop;     /* Offset of TOS from localsplus  */
     PyFrameState f_state;  /* What state the frame is in */
-    bool is_entry;  // Whether this is the "root" frame for the current CFrame.
+    bool is_entry;  // Whether this is the "root" frame for the current _PyCFrame.
     bool is_generator;
     PyObject *localsplus[1];
 } _PyInterpreterFrame;
index 6f1165b7680410bf4f0679b634b19919d785f598..13866ba355e97fc974a0db9bebd6789f7800f70f 100644 (file)
@@ -1616,15 +1616,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
     int oparg;         /* Current opcode argument, if any */
     _Py_atomic_int * const eval_breaker = &tstate->interp->ceval.eval_breaker;
 
-    CFrame cframe;
+    _PyCFrame cframe;
     CallShape call_shape;
     call_shape.kwnames = NULL; // Borrowed reference. Reset by CALL instructions.
 
-    /* WARNING: Because the CFrame lives on the C stack,
+    /* WARNING: Because the _PyCFrame lives on the C stack,
      * but can be accessed from a heap allocated object (tstate)
      * strict stack discipline must be maintained.
      */
-    CFrame *prev_cframe = tstate->cframe;
+    _PyCFrame *prev_cframe = tstate->cframe;
     cframe.use_tracing = prev_cframe->use_tracing;
     cframe.previous = prev_cframe;
     tstate->cframe = &cframe;