Message381227
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 :-) |
|
Date |
User |
Action |
Args |
2020-11-17 12:20:30 | vstinner | set | recipients:
+ vstinner, gvanrossum, terry.reedy, ned.deily, nnemkin, hroncok, lys.nikolaou, pablogsal, miss-islington, brandtbucher |
2020-11-17 12:20:30 | vstinner | set | messageid: <1605615630.61.0.538870269627.issue40939@roundup.psfhosted.org> |
2020-11-17 12:20:30 | vstinner | link | issue40939 messages |
2020-11-17 12:20:30 | vstinner | create | |
|