Comment 8 for bug 1170063

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

There's a problem of API compatibility here. The original point of the base exception is to enable people to catch storm.Error to deal with database exceptions. A few years down the road, I now see that this was a nice outcome, but an ill-conceived way to reach it which shouldn't have been used.

Regardless, we are here today. We need to think if we're breaking the API compatibility, if the workaround suggested works at all, or if there's any other workaround we can think of.

With the original behavior:

- psycopg2 code raises psycopg2.Error
- storm had injected storm.Error as a base of psycopg2.Error
- catching storm.Error catches psycopg2.Error

After this change:

- psycopg2 code raises psycopg2.Error
- storm had injected storm.Error as the base of PsycoPG25Error, which is a subclass of psycopg2.Error
- catching storm.Error does not catch psycopg2.Error

What the workaround attempts is to replace the exception name in the module namespace, but I doubt that will solve the problem, because psycopg2 is mostly in C, which means the module namespace is not really the reference used to raise the exception.

I'd be glad to be wrong here, though. Am I?