##// END OF EJS Templates
Improve error handling in osutil.c...
Petr Kodl -
r7059:6a76cf98 default
parent child Browse files
Show More
@@ -207,9 +207,7 b' static PyObject *listdir(PyObject *self,'
207
207
208 fh = FindFirstFileA(pattern, &fd);
208 fh = FindFirstFileA(pattern, &fd);
209 if (fh == INVALID_HANDLE_VALUE) {
209 if (fh == INVALID_HANDLE_VALUE) {
210 PyErr_SetExcFromWindowsErrWithFilename(PyExc_OSError,
210 PyErr_SetFromWindowsErrWithFilename(GetLastError(), path);
211 GetLastError(),
212 path);
213 goto error_file;
211 goto error_file;
214 }
212 }
215
213
@@ -244,9 +242,7 b' static PyObject *listdir(PyObject *self,'
244 } while (FindNextFileA(fh, &fd));
242 } while (FindNextFileA(fh, &fd));
245
243
246 if (GetLastError() != ERROR_NO_MORE_FILES) {
244 if (GetLastError() != ERROR_NO_MORE_FILES) {
247 PyErr_SetExcFromWindowsErrWithFilename(PyExc_OSError,
245 PyErr_SetFromWindowsErrWithFilename(GetLastError(), path);
248 GetLastError(),
249 path);
250 goto error;
246 goto error;
251 }
247 }
252
248
@@ -294,9 +290,10 b' static PyObject *listdir(PyObject *self,'
294 &path, &pathlen, &statflag, &skip))
290 &path, &pathlen, &statflag, &skip))
295 goto error_parse;
291 goto error_parse;
296
292
297 if (pathlen >= PATH_MAX)
293 if (pathlen >= PATH_MAX) {
294 PyErr_SetString(PyExc_ValueError, "path too long");
298 goto error_parse;
295 goto error_parse;
299
296 }
300 strncpy(fullpath, path, PATH_MAX);
297 strncpy(fullpath, path, PATH_MAX);
301 fullpath[pathlen] = '/';
298 fullpath[pathlen] = '/';
302 keepstat = statflag && PyObject_IsTrue(statflag);
299 keepstat = statflag && PyObject_IsTrue(statflag);
General Comments 0
You need to be logged in to leave comments. Login now