[Python-checkins] r83249 - python/branches/import_unicode/Python/import.c

victor.stinner python-checkins at python.org
Fri Jul 30 03:41:57 CEST 2010


Author: victor.stinner
Date: Fri Jul 30 03:41:57 2010
New Revision: 83249

Log:
NullImporter constructor uses PyUnicode_AsWideChar()

instead of _PyUnicode_AsString(), and GetFileAttributesW() instead of
instead of GetFileAttributesA(), to be fully unicode compliant.

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	Fri Jul 30 03:41:57 2010
@@ -3828,14 +3828,16 @@
         }
 #else /* MS_WINDOWS */
         DWORD rv;
-        char *path;
-        /* FIXME: use PyUnicode_AsWideChar() and GetFileAttributesW() */
-        path = _PyUnicode_AsString(pathobj);
+        wchar_t path[MAXPATHLEN+1];
+        Py_ssize_t len;
+        len = PyUnicode_AsWideChar(pathobj, path, sizeof(path));
+        if (len == -1)
+            return -1;
         /* see issue1293 and issue3677:
          * stat() on Windows doesn't recognise paths like
          * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs.
          */
-        rv = GetFileAttributesA(path);
+        rv = GetFileAttributesW(path);
         if (rv != INVALID_FILE_ATTRIBUTES) {
             /* it exists */
             if (rv & FILE_ATTRIBUTE_DIRECTORY) {


More information about the Python-checkins mailing list