Why does the Python/C API crash on PyRun_SimpleFile?

后端 未结 7 748
一整个雨季
一整个雨季 2020-12-15 07:45

I\'ve been experimenting with embedding different scripting languages in a C++ application, currently I\'m trying Stackless Python 3.1. I\'ve tried several tutorials and exa

7条回答
  •  旧巷少年郎
    2020-12-15 08:11

    I was getting a similar crash & did the below:

       PyObject* PyFileObject = PyFile_FromString("test.py", "r");
       PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), "test.py", 1);
    

    Note that this was in python 2.7 though. I don't know if the API has changed in 3.x.

提交回复
热议问题