STINNER Victor <[email protected]> added the comment:
We should check of the 3 mentioned projects (mod_wsgi,
kdevelop-python, unbound) use the removed functions to suggest a similar
replacement. I understood that there is no drop-in replacement.
unbound does not use to get the parsed Python code as CST, but uses
PyParser_SimpleParseFile() just to display an error message to stderr. I
understand that PyParser_ASTFromFileObject() + PyErr_Print() could be used.
But PyParser_ASTFromFileObject() is low-level, it requires to pass an arena
object. Maybe the *intent* here is to call compile() and display the error
message? Pseudo-code:
---
fp = fopen(filename, "r");
bytes = readall(fp);
PyObject *builtins = PyEval_GetBuiltins();
obj = PyObject_CallMethod(builtins, "compile", "O", bytes);
Py_DECREF(bytes);
if (!obj) {
PyErr_Print();
}
else {
Py_DECREF(obj);
}
fclose(fp);
---
This code is non-trivial :-( Should we provide a *new* C function doing that?
Input: filename
Output: code object
Or maybe I just missed an existing function :-)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40939>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com