[Python-checkins] r83934 - python/branches/import_unicode/Python/import.c
victor.stinner
python-checkins at python.org
Tue Aug 10 18:43:17 CEST 2010
Author: victor.stinner
Date: Tue Aug 10 18:43:17 2010
New Revision: 83934
Log:
document _Py_stat()
and remove FIXMEs
Modified:
python/branches/import_unicode/Python/import.c
Modified: python/branches/import_unicode/Python/import.c
==============================================================================
--- python/branches/import_unicode/Python/import.c (original)
+++ python/branches/import_unicode/Python/import.c Tue Aug 10 18:43:17 2010
@@ -2163,8 +2163,12 @@
#endif
}
-
#ifdef HAVE_STAT
+
+/* Call _wstat() on Windows, or stat() otherwise. Only fill st_mode
+ attribute on Windows. Clear unicode error on path encoding failure.
+ Return 0 on success, -1 on error. */
+
int
_Py_stat(PyObject *unicode, struct stat *statbuf)
{
@@ -2176,19 +2180,18 @@
len = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, path,
sizeof(path) / sizeof(path[0]));
- if (len == -1)
+ if (len == -1) {
+ PyErr_Clear();
return -1;
+ }
err = _wstat(path, &wstatbuf);
- if (!err) {
- /* FIXME: copy more attributes? */
+ if (!err)
statbuf->st_mode = wstatbuf.st_mode;
- }
return err;
#else
int ret;
PyObject *bytes = PyUnicode_EncodeFSDefault(unicode);
if (bytes == NULL) {
- /* FIXME: don't clear error? */
PyErr_Clear();
return -1;
}
More information about the Python-checkins
mailing list