[issue21243] Auto-generate exceptions.c from a Python file

Brett Cannon report at bugs.python.org
Wed Apr 29 14:43:27 CEST 2015


Brett Cannon added the comment:

All of the exception code is written in C. My hypothesis is that it isn't necessary to define *all* exceptions in C. Using a technique similar to importlib, I suspect we could write a bunch of the exceptions that are not critical to interpreter startup in Python for easier maintenance and usage by other interpreters. You would need to make sure the Python objects did get set on the proper C global variables for access by C extension code. You could use BaseException or something temporarily for all exceptions before loading the Python code and then replace the temporary placeholders with the actual exceptions.

IOW, you would need to:

1. Identify which exceptions are necessary to load the Python code holding some built-in exceptions
2. Write Python code for the exceptions which are not necessary for interpreter startup
3. Load the Python file during startup ala importlib
4. Make sure the exceptions make it into the builtin namespace
5. Make sure the exceptions end up in the proper C global variables

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21243>
_______________________________________


More information about the Python-bugs-list mailing list