[Python-checkins] bpo-40941: Fix stackdepth compiler warnings (GH-22377)

Victor Stinner webhook-mailer at python.org
Wed Sep 23 08:07:21 EDT 2020


https://github.com/python/cpython/commit/b7d8d8dbfe83040087a63662e0b908f4b5ac24b0
commit: b7d8d8dbfe83040087a63662e0b908f4b5ac24b0
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-09-23T14:07:16+02:00
summary:

bpo-40941: Fix stackdepth compiler warnings (GH-22377)

Explicitly cast a difference of two pointers to int:
PyFrameObject.f_stackdepth is an int.

files:
M Python/ceval.c

diff --git a/Python/ceval.c b/Python/ceval.c
index 4bb4b820b8e17..6430e792b8c5d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1433,9 +1433,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
         if (_Py_TracingPossible(ceval2) &&
             tstate->c_tracefunc != NULL && !tstate->tracing) {
             int err;
-            /* see maybe_call_line_trace
+            /* see maybe_call_line_trace()
                for expository comments */
-            f->f_stackdepth = stack_pointer-f->f_valuestack;
+            f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
 
             err = maybe_call_line_trace(tstate->c_tracefunc,
                                         tstate->c_traceobj,
@@ -2265,7 +2265,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
             assert(f->f_lasti >= (int)sizeof(_Py_CODEUNIT));
             f->f_lasti -= sizeof(_Py_CODEUNIT);
             f->f_state = FRAME_SUSPENDED;
-            f->f_stackdepth = stack_pointer-f->f_valuestack;
+            f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
             goto exiting;
         }
 
@@ -2282,7 +2282,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
                 retval = w;
             }
             f->f_state = FRAME_SUSPENDED;
-            f->f_stackdepth = stack_pointer-f->f_valuestack;
+            f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
             goto exiting;
         }
 



More information about the Python-checkins mailing list