New submission from Daniel Eloff <dan.el...@gmail.com>:

>>> class Foo(object):
...     pass
...     
>>> raise Foo()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: exceptions must be classes or instances, not Foo
>>> class Foo(Exception):
...     pass
...     
>>> raise Foo()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
Foo
>>> class Foo(BaseException):
...     pass
...     
>>> raise Foo()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
Foo

It seems exceptions can only be subclasses of BaseException, the error message 
is confusing and false.

----------
messages: 100551
nosy: Daniel.Eloff
severity: normal
status: open
title: Misleading exception when raising an object
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8082>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to