diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 5b1fddbe15b98b..6673a5df9a4170 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -540,7 +540,7 @@ typedef struct { PyAPI_FUNC(int) _Py_Instrument(PyCodeObject *co, PyInterpreterState *interp); // Export for '_testinternalcapi' shared extension -PyAPI_FUNC(_Py_CODEUNIT) _Py_GetBaseCodeUnit(PyCodeObject *code, int offset); +PyAPI_FUNC(_Py_CODEUNIT) _Py_GetBaseCodeUnit(PyCodeObject *code, Py_ssize_t offset); extern int _PyInstruction_GetLength(PyCodeObject *code, int offset); diff --git a/Include/internal/pycore_instruments.h b/Include/internal/pycore_instruments.h index 56b55e93a014cb..d134064d9ca24b 100644 --- a/Include/internal/pycore_instruments.h +++ b/Include/internal/pycore_instruments.h @@ -122,7 +122,7 @@ extern int _Py_Instrumentation_GetLine(PyCodeObject *code, _PyCoLineInstrumentationData *line_data, int index); static inline uint8_t -_PyCode_GetOriginalOpcode(_PyCoLineInstrumentationData *line_data, int index) +_PyCode_GetOriginalOpcode(_PyCoLineInstrumentationData *line_data, Py_ssize_t index) { return line_data->data[index*line_data->bytes_per_entry]; } diff --git a/Modules/_testinternalcapi/test_cases.c.h b/Modules/_testinternalcapi/test_cases.c.h index 238e17bea303d3..dcc2b9ef7fa54f 100644 --- a/Modules/_testinternalcapi/test_cases.c.h +++ b/Modules/_testinternalcapi/test_cases.c.h @@ -7946,7 +7946,8 @@ assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER); #if TIER_ONE && defined(Py_DEBUG) if (!PyStackRef_IsNone(frame->f_executable)) { - int i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + assert(i > 0); int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code; assert(opcode == SEND || opcode == FOR_ITER); } @@ -13056,7 +13057,8 @@ assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER); #if TIER_ONE && defined(Py_DEBUG) if (!PyStackRef_IsNone(frame->f_executable)) { - int i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + assert(i > 0); int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code; assert(opcode == SEND || opcode == FOR_ITER); } diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 3bd489122da9d4..cf7a56c95ff600 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1867,7 +1867,8 @@ dummy_func( assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER); #if TIER_ONE && defined(Py_DEBUG) if (!PyStackRef_IsNone(frame->f_executable)) { - int i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + assert(i > 0); int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code; assert(opcode == SEND || opcode == FOR_ITER); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index b6a2821db3007e..67219fc9c61a05 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -9346,7 +9346,8 @@ assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER); #if TIER_ONE && defined(Py_DEBUG) if (!PyStackRef_IsNone(frame->f_executable)) { - int i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + assert(i > 0); int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code; assert(opcode == SEND || opcode == FOR_ITER); } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 2623105656c90c..61d1bb5ec18324 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -7945,7 +7945,8 @@ assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER); #if TIER_ONE && defined(Py_DEBUG) if (!PyStackRef_IsNone(frame->f_executable)) { - int i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + assert(i > 0); int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code; assert(opcode == SEND || opcode == FOR_ITER); } @@ -13053,7 +13054,8 @@ assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER); #if TIER_ONE && defined(Py_DEBUG) if (!PyStackRef_IsNone(frame->f_executable)) { - int i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame); + assert(i > 0); int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code; assert(opcode == SEND || opcode == FOR_ITER); } diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 51bcbfdb3b6c55..00ac171658815e 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -635,7 +635,7 @@ sanity_check_instrumentation(PyCodeObject *code) /* Get the underlying code unit, stripping instrumentation and ENTER_EXECUTOR */ _Py_CODEUNIT -_Py_GetBaseCodeUnit(PyCodeObject *code, int i) +_Py_GetBaseCodeUnit(PyCodeObject *code, Py_ssize_t i) { _Py_CODEUNIT *src_instr = _PyCode_CODE(code) + i; _Py_CODEUNIT inst = {