summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-05-05 01:34:02 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-05-05 01:34:02 (GMT)
commit229cee2d3dc2d962d5cbda96f2411c5cec0a9293 (patch)
tree3a474da4aafdfa18c6b6f8848c4792e70e5b9ad0 /Objects
parent2ebc4d8054615e9e5ad8ef6e35aad6ac419233c8 (diff)
downloadcpython-229cee2d3dc2d962d5cbda96f2411c5cec0a9293.zip
cpython-229cee2d3dc2d962d5cbda96f2411c5cec0a9293.tar.gz
cpython-229cee2d3dc2d962d5cbda96f2411c5cec0a9293.tar.bz2
Deprecate BaseException.message as per PEP 352.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 65419de..927114e 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -212,13 +212,6 @@ static PySequenceMethods BaseException_as_sequence = {
0 /* sq_inplace_repeat; */
};
-static PyMemberDef BaseException_members[] = {
- {"message", T_OBJECT, offsetof(PyBaseExceptionObject, message), 0,
- PyDoc_STR("exception message")},
- {NULL} /* Sentinel */
-};
-
-
static PyObject *
BaseException_get_dict(PyBaseExceptionObject *self)
{
@@ -274,9 +267,42 @@ BaseException_set_args(PyBaseExceptionObject *self, PyObject *val)
return 0;
}
+static PyObject *
+BaseException_get_message(PyBaseExceptionObject *self)
+{
+ int ret;
+ ret = PyErr_WarnEx(PyExc_DeprecationWarning,
+ "BaseException.message has been deprecated as "
+ "of Python 2.6",
+ 1);
+ if (ret == -1)
+ return NULL;
+
+ Py_INCREF(self->message);
+ return self->message;
+}
+
+static int
+BaseException_set_message(PyBaseExceptionObject *self, PyObject *val)
+{
+ int ret;
+ ret = PyErr_WarnEx(PyExc_DeprecationWarning,
+ "BaseException.message has been deprecated as "
+ "of Python 2.6",
+ 1);
+ if (ret == -1)
+ return -1;
+ Py_INCREF(val);
+ Py_DECREF(self->message);
+ self->message = val;
+ return 0;
+}
+
static PyGetSetDef BaseException_getset[] = {
{"__dict__", (getter)BaseException_get_dict, (setter)BaseException_set_dict},
{"args", (getter)BaseException_get_args, (setter)BaseException_set_args},
+ {"message", (getter)BaseException_get_message,
+ (setter)BaseException_set_message},
{NULL},
};
@@ -312,7 +338,7 @@ static PyTypeObject _PyExc_BaseException = {
0, /* tp_iter */
0, /* tp_iternext */
BaseException_methods, /* tp_methods */
- BaseException_members, /* tp_members */
+ 0, /* tp_members */
BaseException_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */