'How to convert C string to Python exception

I'm trying to figure out how to convert a C string such as "RuntimeError" or "IOError" to the corresponding Python exception PyExc_RuntimeError and PyExc_IOError.

If I were writing in Python, I could do something like __builtins__.__dict__[name], but I can't seem to find the functions required to access __builtins__ or to lookup a name in that module.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source