Raising objects
Steven Taschuk
staschuk at telusplanet.net
Thu May 1 21:46:09 EDT 2003
Quoth Alex Martelli:
[...]
> We probably do need to aim at a world where (except for backwards
> compatibility) one raises an instance (of some subclass of
> NewException), period -- getting out of the current "raise klas"
> equalling "raise klas()" confusion. [...]
After much reflection, I agree with this. The ultimate objective
should be: raise any instance of (any subclass of) (New)Exception;
catch e if and only if the except clause names a type of which e
is an instance.
> [...] But how to get there ain't
> obvious. Perhaps a first step might be to patch all of the standard
> library to eradicate the "raise klas" and "raise klas, blah" uses.
> Then optional warnings for raising strings or anything else except
> instances of some subclass of Exception (but we can't do that until
> the standard library's conforming to the new preferred ways). Then
> make the warnings default to on. Then...
I think the migration path is not difficult, though it will take
some time; some of it is disruptive enough that it should probably
occur at the major-version timescale.
Time to write a PEP, I think.
--
Steven Taschuk Aral: "Confusion to the enemy, boy."
staschuk at telusplanet.net Mark: "Turn-about is fair play, sir."
-- _Mirror Dance_, Lois McMaster Bujold
More information about the Python-list
mailing list