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, lys.nikolaou, miss-islington, ned.deily, nnemkin, pablogsal, terry.reedy, vstinner
Date 2020-11-12.15:18:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> There is no mention of PyParser_SimpleParseFile() removal in What's New in Python 3.10.

By the way, is there a replacement for this function? The unbound project uses it to display a SyntaxError when PyRun_SimpleFile() fails.

Petr Menšík asked:

"Could we instead modify PyRun_SimpleFile call to produce just one exception, then print it to stderr once and once into the log? (...) But it seems PyRun_SimpleFile does not throw Exception. Can you recommend variant or flags, which would make it raise an Exception, which log_py_err() would then to log file? After commenting out PyParser_SimpleParseFile it reports None, so it did not already raise an exception."

unbound used the removed function PyParser_SimpleParseFile() in pythonmod/pythonmod.c. Extract of unbound-1.12.0.tar.gz:

   if (PyRun_SimpleFile(script_py, pe->fname) < 0) {
      log_err("pythonmod: can't parse Python script %s", pe->fname);
      /* print the error to logs too, run it again */
      fseek(script_py, 0, SEEK_SET);
      /* we don't run the file, like this, because then side-effects
       *    s = PyRun_File(script_py, pe->fname, Py_file_input, 
       *        PyModule_GetDict(PyImport_AddModule("__main__")), pe->dict);
       * could happen (again). Instead we parse the file again to get
       * the error string in the logs, for when the daemon has stderr
       * removed.  SimpleFile run already printed to stderr, for then
       * this is called from unbound-checkconf or unbound -dd the user
       * has a nice formatted error.
      /* ignore the NULL return of _node, it is NULL due to the parse failure
       * that we are expecting */
      (void)PyParser_SimpleParseFile(script_py, pe->fname, Py_file_input);
      return 0;
Date User Action Args
2020-11-12 15:18:32vstinnersetrecipients: + vstinner, gvanrossum, terry.reedy, ned.deily, nnemkin, lys.nikolaou, pablogsal, miss-islington, brandtbucher
2020-11-12 15:18:32vstinnersetmessageid: <>
2020-11-12 15:18:32vstinnerlinkissue40939 messages
2020-11-12 15:18:32vstinnercreate