Show More
@@ -121,6 +121,27 b' static void listdir_stat_dealloc(PyObjec' | |||
|
121 | 121 | o->ob_type->tp_free(o); |
|
122 | 122 | } |
|
123 | 123 | |
|
124 | static PyObject *listdir_stat_getitem(PyObject *self, PyObject *key) | |
|
125 | { | |
|
126 | long index = PyLong_AsLong(key); | |
|
127 | if (index == -1 && PyErr_Occurred()) { | |
|
128 | return NULL; | |
|
129 | } | |
|
130 | if (index != 8) { | |
|
131 | PyErr_Format(PyExc_IndexError, "osutil.stat objects only " | |
|
132 | "support stat.ST_MTIME in " | |
|
133 | "__getitem__"); | |
|
134 | return NULL; | |
|
135 | } | |
|
136 | return listdir_stat_st_mtime(self, NULL); | |
|
137 | } | |
|
138 | ||
|
139 | static PyMappingMethods listdir_stat_type_mapping_methods = { | |
|
140 | (lenfunc)NULL, /* mp_length */ | |
|
141 | (binaryfunc)listdir_stat_getitem, /* mp_subscript */ | |
|
142 | (objobjargproc)NULL, /* mp_ass_subscript */ | |
|
143 | }; | |
|
144 | ||
|
124 | 145 | static PyTypeObject listdir_stat_type = { |
|
125 | 146 | PyVarObject_HEAD_INIT(NULL, 0) /* header */ |
|
126 | 147 | "osutil.stat", /*tp_name*/ |
@@ -134,7 +155,7 b' static PyTypeObject listdir_stat_type = ' | |||
|
134 | 155 | 0, /*tp_repr*/ |
|
135 | 156 | 0, /*tp_as_number*/ |
|
136 | 157 | 0, /*tp_as_sequence*/ |
|
137 | 0, /*tp_as_mapping*/ | |
|
158 | &listdir_stat_type_mapping_methods, /*tp_as_mapping*/ | |
|
138 | 159 | 0, /*tp_hash */ |
|
139 | 160 | 0, /*tp_call*/ |
|
140 | 161 | 0, /*tp_str*/ |
@@ -1352,7 +1373,7 b' static PyMethodDef methods[] = {' | |||
|
1352 | 1373 | {NULL, NULL} |
|
1353 | 1374 | }; |
|
1354 | 1375 | |
|
1355 |
static const int version = |
|
|
1376 | static const int version = 4; | |
|
1356 | 1377 | |
|
1357 | 1378 | #ifdef IS_PY3K |
|
1358 | 1379 | static struct PyModuleDef osutil_module = { |
General Comments 0
You need to be logged in to leave comments.
Login now