On 06/14/2012 02:33 PM, Niall Douglas wrote:
Do you think that this answer is worth adding to the BPL FAQ?
Normally you don't need to derive from Python's Exception object, and
indeed in my own custom exception implementations I never did so.
However, if this has changed, an FAQ entry is appropriate.
Python is certainly going in that direction. You used to be able to do
all kinds of crazy things such as using strings as exceptions but
current versions are much stricter about what you can raise. This is
what Python 2 says:
>>> raise "hell"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must be old-style classes or derived from
BaseException, not str
and here is Python 3:
>>> raise "the dead"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must derive from BaseException
Wichert.
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig