Код: Выделить всё
class TestFailed(BaseException):
def __new__(self, m):
self.message = m
def __str__(self):
return self.message
try:
raise TestFailed('Oops')
except TestFailed as x:
print x
< /code>
Когда я его запускаю, я получаю: < /p>
Traceback (most recent call last):
File "x.py", line 9, in
raise TestFailed('Oops')
TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType
Подробнее здесь: https://stackoverflow.com/questions/795 ... baseexcept