How to retrieve filename and lineno attribute of SyntaxError

前端 未结 2 1206
故里飘歌
故里飘歌 2020-12-19 04:27

I have embedded python interpreter in my application. I use it to run python scripts using PyRun_String() API. I can fetch error information using PyErr_F

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 04:41

    The attributes are set on the the PySyntaxErrorObject struct, but be aware that the struct is not exposed if you are adhering to Python's stable ABI. Otherwise you should be able to use a PyObject_GetAttr* function to get at the attributes.

提交回复
热议问题