Show More
@@ -128,17 +128,27 b' static PyObject* bserobj_getattrro(PyObj' | |||
|
128 | 128 | Py_ssize_t i, n; |
|
129 | 129 | PyObject* name_bytes = NULL; |
|
130 | 130 | PyObject* ret = NULL; |
|
131 | const char* namestr; | |
|
131 | const char* namestr = NULL; | |
|
132 | 132 | |
|
133 | 133 | if (PyIndex_Check(name)) { |
|
134 | 134 | i = PyNumber_AsSsize_t(name, PyExc_IndexError); |
|
135 | 135 | if (i == -1 && PyErr_Occurred()) { |
|
136 | 136 | goto bail; |
|
137 | 137 | } |
|
138 | ||
|
139 | if (i == 8 && PySequence_Size(obj->values) < 9) { | |
|
140 | // Hack alert: Python 3 removed support for os.stat().st_mtime | |
|
141 | // being an integer.Instead, if you need an integer, you have to | |
|
142 | // use os.stat()[stat.ST_MTIME] instead. stat.ST_MTIME is 8, and | |
|
143 | // our stat tuples are shorter than that, so we can detect | |
|
144 | // requests for index 8 on tuples shorter than that and return | |
|
145 | // st_mtime instead. | |
|
146 | namestr = "st_mtime"; | |
|
147 | } else { | |
|
138 | 148 | ret = PySequence_GetItem(obj->values, i); |
|
139 | 149 | goto bail; |
|
140 | 150 | } |
|
141 | ||
|
151 | } else { | |
|
142 | 152 | // We can be passed in Unicode objects here -- we don't support anything other |
|
143 | 153 | // than UTF-8 for keys. |
|
144 | 154 | if (PyUnicode_Check(name)) { |
@@ -150,6 +160,7 b' static PyObject* bserobj_getattrro(PyObj' | |||
|
150 | 160 | } else { |
|
151 | 161 | namestr = PyBytes_AsString(name); |
|
152 | 162 | } |
|
163 | } | |
|
153 | 164 | |
|
154 | 165 | if (namestr == NULL) { |
|
155 | 166 | goto bail; |
General Comments 0
You need to be logged in to leave comments.
Login now