summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-11-05 19:17:52 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-11-05 19:17:52 (GMT)
commit878ce389a08594a805cf382a73414be02143396c (patch)
treec1c9a9b02e23dd3461d2c3bc894a2d99dc5c8771 /Objects/rangeobject.c
parent03b081938954a333fb5473977ee8d22e9699bc5b (diff)
downloadcpython-878ce389a08594a805cf382a73414be02143396c.zip
cpython-878ce389a08594a805cf382a73414be02143396c.tar.gz
cpython-878ce389a08594a805cf382a73414be02143396c.tar.bz2
add introspection to range objects (closes #9896)
Patch by Daniel Urban.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r--Objects/rangeobject.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index c1e9e54..fb6a5fe 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -1,6 +1,7 @@
/* Range object implementation */
#include "Python.h"
+#include "structmember.h"
/* Support objects whose length is > PY_SSIZE_T_MAX.
@@ -880,6 +881,13 @@ static PyMethodDef range_methods[] = {
{NULL, NULL} /* sentinel */
};
+static PyMemberDef range_members[] = {
+ {"start", T_OBJECT_EX, offsetof(rangeobject, start), READONLY},
+ {"stop", T_OBJECT_EX, offsetof(rangeobject, stop), READONLY},
+ {"step", T_OBJECT_EX, offsetof(rangeobject, step), READONLY},
+ {0}
+};
+
PyTypeObject PyRange_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"range", /* Name of this type */
@@ -909,7 +917,7 @@ PyTypeObject PyRange_Type = {
range_iter, /* tp_iter */
0, /* tp_iternext */
range_methods, /* tp_methods */
- 0, /* tp_members */
+ range_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */