Skip to content

Commit 7938098

Browse files
Use Py_ssize_t for offset
1 parent 6cd92c0 commit 7938098

7 files changed

Lines changed: 15 additions & 9 deletions

File tree

Include/internal/pycore_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ typedef struct {
540540
PyAPI_FUNC(int) _Py_Instrument(PyCodeObject *co, PyInterpreterState *interp);
541541

542542
// Export for '_testinternalcapi' shared extension
543-
PyAPI_FUNC(_Py_CODEUNIT) _Py_GetBaseCodeUnit(PyCodeObject *code, int offset);
543+
PyAPI_FUNC(_Py_CODEUNIT) _Py_GetBaseCodeUnit(PyCodeObject *code, Py_ssize_t offset);
544544

545545
extern int _PyInstruction_GetLength(PyCodeObject *code, int offset);
546546

Include/internal/pycore_instruments.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ extern int
122122
_Py_Instrumentation_GetLine(PyCodeObject *code, _PyCoLineInstrumentationData *line_data, int index);
123123

124124
static inline uint8_t
125-
_PyCode_GetOriginalOpcode(_PyCoLineInstrumentationData *line_data, int index)
125+
_PyCode_GetOriginalOpcode(_PyCoLineInstrumentationData *line_data, Py_ssize_t index)
126126
{
127127
return line_data->data[index*line_data->bytes_per_entry];
128128
}

Modules/_testinternalcapi/test_cases.c.h

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,8 @@ dummy_func(
18671867
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
18681868
#if TIER_ONE && defined(Py_DEBUG)
18691869
if (!PyStackRef_IsNone(frame->f_executable)) {
1870-
int i = (int)(frame->instr_ptr - _PyFrame_GetBytecode(frame));
1870+
Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
1871+
assert(i > 0);
18711872
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
18721873
assert(opcode == SEND || opcode == FOR_ITER);
18731874
}

Python/executor_cases.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/instrumentation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ sanity_check_instrumentation(PyCodeObject *code)
635635

636636
/* Get the underlying code unit, stripping instrumentation and ENTER_EXECUTOR */
637637
_Py_CODEUNIT
638-
_Py_GetBaseCodeUnit(PyCodeObject *code, int i)
638+
_Py_GetBaseCodeUnit(PyCodeObject *code, Py_ssize_t i)
639639
{
640640
_Py_CODEUNIT *src_instr = _PyCode_CODE(code) + i;
641641
_Py_CODEUNIT inst = {

0 commit comments

Comments
 (0)