This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients brandtbucher, gvanrossum, hroncok, lys.nikolaou, miss-islington, ned.deily, nnemkin, pablogsal, terry.reedy, vstinner
Date 2020-11-17.12:20:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605615630.61.0.538870269627.issue40939@roundup.psfhosted.org>
In-reply-to
Content
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 :-)
History
Date User Action Args
2020-11-17 12:20:30vstinnersetrecipients: + vstinner, gvanrossum, terry.reedy, ned.deily, nnemkin, hroncok, lys.nikolaou, pablogsal, miss-islington, brandtbucher
2020-11-17 12:20:30vstinnersetmessageid: <1605615630.61.0.538870269627.issue40939@roundup.psfhosted.org>
2020-11-17 12:20:30vstinnerlinkissue40939 messages
2020-11-17 12:20:30vstinnercreate