diff --git a/library/grt/src/python_context.cpp b/library/grt/src/python_context.cpp index 49ea3ce..a6f59f2 100644 --- a/library/grt/src/python_context.cpp +++ b/library/grt/src/python_context.cpp @@ -31,7 +31,6 @@ #include "base/wb_memory.h" // python internals -#include #include #include #include @@ -1598,7 +1597,7 @@ int PythonContext::run_file(const std::string &file, bool interactive) { If line_buffer is null, the passed buffer will be expected to contain complete code. */ int PythonContext::run_buffer(const std::string &buffer, std::string *line_buffer) { - node *n; + PyObject *n; PyObject *result; PyObject *mainmod; PyObject *globals; @@ -1617,8 +1616,16 @@ int PythonContext::run_buffer(const std::string &buffer, std::string *line_buffe WillEnterPython lock; - n = PyParser_SimpleParseStringFlags(line_buffer ? line_buffer->c_str() : buffer.c_str(), - line_buffer ? Py_single_input : Py_file_input, 0); + /* The changelog says: + A call to PyParser_SimpleParseStringFlags followed by PyNode_Compile can + be replaced by calling Py_CompileString(). + + We do not have PyNode_Compile()... But looks like `n` is not used anyway. + + https://docs.python.org/3/whatsnew/3.10.html#changes-in-the-c-api */ + + n = Py_CompileString(line_buffer ? line_buffer->c_str() : buffer.c_str(), NULL, + line_buffer ? Py_single_input : Py_file_input); if (n && (!buffer.empty() && (buffer[0] == ' ' || buffer[0] == '\t')) && line_buffer) { return 0; // continued line @@ -1651,7 +1658,7 @@ int PythonContext::run_buffer(const std::string &buffer, std::string *line_buffe return -1; } - PyNode_Free(n); + Py_DECREF(n); PyErr_Clear(); // command is supposedly complete, try to execute it