Skip to content

Commit b7d8d8d

Browse files
authored
bpo-40941: Fix stackdepth compiler warnings (GH-22377)
Explicitly cast a difference of two pointers to int: PyFrameObject.f_stackdepth is an int.
1 parent 71f2ff4 commit b7d8d8d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/ceval.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1433,9 +1433,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
14331433
if (_Py_TracingPossible(ceval2) &&
14341434
tstate->c_tracefunc != NULL && !tstate->tracing) {
14351435
int err;
1436-
/* see maybe_call_line_trace
1436+
/* see maybe_call_line_trace()
14371437
for expository comments */
1438-
f->f_stackdepth = stack_pointer-f->f_valuestack;
1438+
f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
14391439

14401440
err = maybe_call_line_trace(tstate->c_tracefunc,
14411441
tstate->c_traceobj,
@@ -2265,7 +2265,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
22652265
assert(f->f_lasti >= (int)sizeof(_Py_CODEUNIT));
22662266
f->f_lasti -= sizeof(_Py_CODEUNIT);
22672267
f->f_state = FRAME_SUSPENDED;
2268-
f->f_stackdepth = stack_pointer-f->f_valuestack;
2268+
f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
22692269
goto exiting;
22702270
}
22712271

@@ -2282,7 +2282,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
22822282
retval = w;
22832283
}
22842284
f->f_state = FRAME_SUSPENDED;
2285-
f->f_stackdepth = stack_pointer-f->f_valuestack;
2285+
f->f_stackdepth = (int)(stack_pointer - f->f_valuestack);
22862286
goto exiting;
22872287
}
22882288

0 commit comments

Comments
 (0)