Idea: Replacing the Exceptions Module

February 9, 2000 | Fredrik Lundh

June 5, 2000: Thanks to Barry Warsaw, an improved version of this module has now been added to Python 1.6.

The exceptions module defines class-versions of all standard exceptions. It’s automatically imported by Python interpreter during startup.

In 1.5.2, this module is implemented in Python, which means that you need to have Python modules installed (and the Python path set to something reasonable) if you want to use class exceptions in your program.

This experimental module provides an alternative. It reimplements as a C module, which can be statically linked to the Python interpreter. And it’s faster than the Python version, of course.

Usage: The current snapshot is highly experimental. To try it out, compile _exceptions.c into a C module, and create a file called which simply imports everything from the _exceptions module.

Or rename the C file, if you prefer (if you do, don’t forget to change the initialization code).

Status: This is work in progress. The current release seems to work, but it doesn’t provide full implementations for the SyntaxError and EnvironmentError classes.



A Django site. rendered by a django application. hosted by webfaction.