What is the reasoning behind allowing the raise of a tuple -- but
really only raising its (recursively) first element?

It seems to have been added (with different spelling) in 1991 (rev
2625) as the only alternative to string exceptions.  (You couldn't
raise a class or instance.)  I assume it was kept for backwards
compatibility.

Were there other reasons, or should this be removed in python 3?

Looking at ceval.c

/* We support the following forms of raise:
...
           raise <classinstance>, None
...
           In addition, raise <tuple>, <anything> is the same as
           raising the tuple's first item (and it better have one!);
           this rule is applied recursively.
...
/* Next, repeatedly, replace a tuple exception with its first item */
        while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {
                PyObject *tmp = type;
                type = PyTuple_GET_ITEM(type, 0);
                Py_INCREF(type);
                Py_DECREF(tmp);
        }
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to