summaryrefslogtreecommitdiffstats
path: root/Python/traceback.c
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-08-14 17:53:54 (GMT)
committerCollin Winter <collinw@gmail.com>2007-08-14 17:53:54 (GMT)
commit3eed76522389d55248a71aa8c83203aa3ae0873b (patch)
tree9a52b1a1b21046fafcc54736ef173e1cfc8fe8d1 /Python/traceback.c
parentee634a4013ff6321aecd132498721ebfb734a4cc (diff)
downloadcpython-3eed76522389d55248a71aa8c83203aa3ae0873b.zip
cpython-3eed76522389d55248a71aa8c83203aa3ae0873b.tar.gz
cpython-3eed76522389d55248a71aa8c83203aa3ae0873b.tar.bz2
Bug #1772489: make dir() work on traceback objects again.
Diffstat (limited to 'Python/traceback.c')
-rw-r--r--Python/traceback.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index aa99ab4..5bb8841 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -11,6 +11,18 @@
#define OFF(x) offsetof(PyTracebackObject, x)
+static PyObject *
+tb_dir(PyTracebackObject *self)
+{
+ return Py_BuildValue("[ssss]", "tb_frame", "tb_next",
+ "tb_lasti", "tb_lineno");
+}
+
+static PyMethodDef tb_methods[] = {
+ {"__dir__", (PyCFunction)tb_dir, METH_NOARGS},
+ {NULL, NULL, 0, NULL},
+};
+
static PyMemberDef tb_memberlist[] = {
{"tb_next", T_OBJECT, OFF(tb_next), READONLY},
{"tb_frame", T_OBJECT, OFF(tb_frame), READONLY},
@@ -73,7 +85,7 @@ PyTypeObject PyTraceBack_Type = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- 0, /* tp_methods */
+ tb_methods, /* tp_methods */
tb_memberlist, /* tp_members */
0, /* tp_getset */
0, /* tp_base */