[DB-SIG] PEP 249 in obsolete for Python 3000
vernondcole at gmail.com
Thu Jan 29 20:15:23 CET 2009
I am busy hacking on code in an attempt to make adodbapi actually work in
three environments: CPython 2.3 to 2.6, CPython 3.0, and IronPython. One of
the first things that failed, when attempting to run on Python 3.0, was the
test for exception definitions. I quote:
The module should make all error information available through
> these exceptions or subclasses thereof:
> Exception raised for important warnings like data
> truncations while inserting, etc. It must be a subclass of
> the Python StandardError (defined in the module
> Exception that is the base class of all other error
> exceptions. You can use this to catch all errors with one
> single 'except' statement. Warnings are not considered
> errors and thus should not use this class as base. It must
> be a subclass of the Python StandardError (defined in the
> module exceptions).
This is impossible with Python 3.0, since there is neither an "exceptions"
module nor a "StandardError".
Mark Hammond provided the following workaround:
> from exceptions import StandardError as _BaseException
> except ImportError:
> # py3k
> _BaseException = Exception
> class Error(_BaseException):
> class Warning(_BaseException):
This makes the code work fine, except that, by strict definition, it
violates the api.
So it would seem that we need to also patch the PEP.
How is that done?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the DB-SIG