Python calling C: how could C send Python's line number it has been called from?

StackOverflow https://stackoverflow.com/questions/17348492

  •  01-06-2022
  •  | 
  •  

Вопрос

I have a Python code calling some C code (.so file).

Is there a way, from within the C code, go get the line number it has been called from at the Python side?

Это было полезно?

Решение

I eventually found the PyFrame_GetLineNumber(PyFrameObject *f) C function, whose source is located in frameobject.c.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top