In addition, PyParser_ASTFromString is no longer supported. In Python 3.9 and before this returned a concrete parse tree. The parser was rewritten and the whole concept of a concrete parse tree no longer exists. See PEP 617. There are corresponding APIs to get an AST.
You’re using the old removed low-level API. Why not calling the built-in compile() function instead to compile a string to a Python object instead? Sorry, I don’t recall if there is a public C API just for that.
PyEval_GetBuiltins() can be used to get built-in functions.
You probably want to use on of the Py_CompileStringExFlags or one of the other compile variants to compile, or even PyRun_String without explicitly compiling.