support older Python versions · vmprof/vmprof-python@a3a58f0 · GitHub
Skip to content

Commit a3a58f0

Browse files
support older Python versions
1 parent 256991f commit a3a58f0

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/_vmprof.c

Lines changed: 4 additions & 0 deletions

src/vmp_stack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#include "vmprof.h"
1515
#include "compat.h"
1616

17+
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
1718
#include "internal/pycore_frame.h"
19+
#endif
1820

1921
#ifdef VMP_SUPPORTS_NATIVE_PROFILING
2022

@@ -102,7 +104,9 @@ static PY_STACK_FRAME_T * _write_python_stack_entry(PY_STACK_FRAME_T * frame, vo
102104
result[*depth] = (void*) (int64_t) PyFrame_GetLineNumber(frame);
103105
*depth = *depth + 1;
104106
}
107+
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
105108
if (!_PyFrame_IsIncomplete(frame))
109+
#endif
106110
result[*depth] = (void*)CODE_ADDR_TO_UID(FRAME_CODE(frame));
107111
*depth = *depth + 1;
108112
#else

src/vmprof.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ int IS_VMPROF_EVAL(void * ptr);
7575
#define PY_EVAL_RETURN_T PyObject
7676
#define PY_THREAD_STATE_T PyThreadState
7777
#define FRAME_STEP(f) f->f_back
78+
79+
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
7880
#define FRAME_CODE(f) f->f_frame->f_code
81+
#else
82+
#define FRAME_CODE(f) f->f_code
83+
#endif // PY_VERSION_HEX >= 0x030b00f0
7984

8085
#if CPYTHON_HAS_FRAME_EVALUATION
8186
#define IS_VMPROF_EVAL(PTR) PTR == (void*)_PyEval_EvalFrameDefault

src/vmprof_unix.c

Lines changed: 4 additions & 0 deletions

0 commit comments

Comments
 (0)