? .test.py.swp ? Locating: ? diff.txt ? stACHwxZ ? test.py ? test_unicode.py ? Lib/test/.test_descr.py.swp ? Python/.errors.c.swp Index: Python/ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.314 diff -u -c -5 -r2.314 ceval.c *** Python/ceval.c 14 Jun 2002 13:53:29 -0000 2.314 --- Python/ceval.c 11 Jul 2002 15:35:37 -0000 *************** *** 2672,2681 **** --- 2672,2683 ---- raise , None raise , raise , None raise , raise , None + raise , None + raise , An omitted second argument is the same as None. In addition, raise , is the same as raising the tuple's first item (and it better have one!); *************** *** 2733,2749 **** value = type; type = (PyObject*) ((PyInstanceObject*)type)->in_class; Py_INCREF(type); } } else { ! /* Not something you can raise. You get an exception ! anyway, just not what you specified :-) */ ! PyErr_Format(PyExc_TypeError, ! "exceptions must be strings, classes, or " ! "instances, not %s", type->ob_type->tp_name); ! goto raise_error; } PyErr_Restore(type, value, tb); if (tb == NULL) return WHY_EXCEPTION; else --- 2735,2768 ---- value = type; type = (PyObject*) ((PyInstanceObject*)type)->in_class; Py_INCREF(type); } } + else if (PyType_Check(type) && value != Py_None) { + /* Raising an object with an explicit type specification + * The specified type and the type of the object must be the same */ + if (value->ob_type != (PyTypeObject *)type) { + PyErr_SetString(PyExc_TypeError, + "object exception with type must have the same type"); + goto raise_error; + } + } else { ! /* Raising an object. The value should be a dummy. ! * The exception type will be the type of the object */ ! if (value != Py_None) { ! PyErr_SetString(PyExc_TypeError, ! "object exception may not have a separate value"); ! goto raise_error; ! } ! else { ! /* Normalize to raise type(), */ ! Py_DECREF(value); ! value = type; ! type = (PyObject *)type->ob_type; ! Py_INCREF(type); ! } } PyErr_Restore(type, value, tb); if (tb == NULL) return WHY_EXCEPTION; else Index: Python/errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.70 diff -u -c -5 -r2.70 errors.c *** Python/errors.c 30 Jun 2002 15:26:10 -0000 2.70 --- Python/errors.c 11 Jul 2002 15:35:41 -0000 *************** *** 106,115 **** --- 106,117 ---- err = (PyObject*)((PyInstanceObject*)err)->in_class; if (PyClass_Check(err) && PyClass_Check(exc)) return PyClass_IsSubclass(err, exc); + if (PyType_Check(exc)) + return PyObject_IsSubclass(err, exc); return err == exc; } int