r54015 - in python/branches/p3yk_no_args_on_exc: Lib/test/test_exceptions.py Objects/exceptions.c

Author: brett.cannon Date: Wed Feb 28 05:56:17 2007 New Revision: 54015 Modified: python/branches/p3yk_no_args_on_exc/Lib/test/test_exceptions.py python/branches/p3yk_no_args_on_exc/Objects/exceptions.c Log: Get 'args' removal from exceptions to be able to pass test_exceptions, test_exception_variations, and test_pep352. Modified: python/branches/p3yk_no_args_on_exc/Lib/test/test_exceptions.py ============================================================================== --- python/branches/p3yk_no_args_on_exc/Lib/test/test_exceptions.py (original) +++ python/branches/p3yk_no_args_on_exc/Lib/test/test_exceptions.py Wed Feb 28 05:56:17 2007 @@ -259,7 +259,6 @@ except BaseException as e: if type(e) is not exc: raise - print(repr(e), ':', args) # Verify module name self.assertEquals(type(e).__module__, '__builtin__') # Verify no ref leaks in Exc_str() Modified: python/branches/p3yk_no_args_on_exc/Objects/exceptions.c ============================================================================== --- python/branches/p3yk_no_args_on_exc/Objects/exceptions.c (original) +++ python/branches/p3yk_no_args_on_exc/Objects/exceptions.c Wed Feb 28 05:56:17 2007 @@ -1534,6 +1534,27 @@ return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); } + +static PyObject * +UnicodeError_reduce(PyUnicodeErrorObject *self) +{ + if (self->dict) + return Py_BuildValue("(O, (O, O, O, O, O), O)", self->ob_type, + self->encoding, self->object, self->start, + self->end, self->reason, self->dict); + else + return Py_BuildValue("(O, (O, O, O, O, O))", self->ob_type, + self->encoding, self->object, self->start, + self->end, self->reason); + +} + + +static PyMethodDef UnicodeError_methods[] = { + {"__reduce__", (PyCFunction)UnicodeError_reduce, METH_NOARGS}, + {NULL} +}; + static PyMemberDef UnicodeError_members[] = { {"message", T_OBJECT, offsetof(PyUnicodeErrorObject, message), 0, PyDoc_STR("exception message")}, @@ -1612,8 +1633,9 @@ (reprfunc)UnicodeEncodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, PyDoc_STR("Unicode encoding error."), (traverseproc)UnicodeError_traverse, - (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, - 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), + (inquiry)UnicodeError_clear, 0, 0, 0, 0, UnicodeError_methods, + UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, + offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeEncodeError_init, 0, BaseException_new, }; PyObject *PyExc_UnicodeEncodeError = (PyObject *)&_PyExc_UnicodeEncodeError; @@ -1685,9 +1707,10 @@ (reprfunc)UnicodeDecodeError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, - (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, - 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), - (initproc)UnicodeDecodeError_init, 0, BaseException_new, + (inquiry)UnicodeError_clear, 0, 0, 0, 0, UnicodeError_methods, + UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, + offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeDecodeError_init, 0, + BaseException_new, }; PyObject *PyExc_UnicodeDecodeError = (PyObject *)&_PyExc_UnicodeDecodeError; @@ -1775,6 +1798,27 @@ ); } + +static PyObject * +UnicodeTranslateError_reduce(PyUnicodeErrorObject *self) +{ + if (self->dict) + return Py_BuildValue("(O, (O, O, O, O), O)", self->ob_type, + self->object, self->start, self->end, + self->reason, self->dict); + else + return Py_BuildValue("(O, (O, O, O, O))", self->ob_type, + self->object, self->start, self->end, + self->reason); +} + + +static PyMethodDef UnicodeTranslateError_methods[] = { + {"__reduce__", (PyCFunction)UnicodeTranslateError_reduce, METH_NOARGS}, + {NULL} +}; + + static PyTypeObject _PyExc_UnicodeTranslateError = { PyObject_HEAD_INIT(NULL) 0, @@ -1784,8 +1828,9 @@ (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, - (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, - 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), + (inquiry)UnicodeError_clear, 0, 0, 0, 0, UnicodeTranslateError_methods, + UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, + offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, BaseException_new, }; PyObject *PyExc_UnicodeTranslateError = (PyObject *)&_PyExc_UnicodeTranslateError;
participants (1)
-
brett.cannon