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

victor.stinner python-checkins at python.org
Fri Jul 9 01:33:18 CEST 2010


Author: victor.stinner
Date: Fri Jul  9 01:33:17 2010
New Revision: 82709

Log:
parse_source_module() uses PyUnicode_EncodeFSDefault()

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  9 01:33:17 2010
@@ -1151,16 +1151,17 @@
     PyCodeObject *co = NULL;
     mod_ty mod;
     PyCompilerFlags flags;
+    PyObject *pathbytes;
     char *pathname;
 
     PyArena *arena = PyArena_New();
     if (arena == NULL)
         return NULL;
 
-    /* FIXME: use PyUnicode_EncodeFSDefault() */
-    pathname = _PyUnicode_AsString(pathobj);
-    if (pathname == NULL)
+    pathbytes = PyUnicode_EncodeFSDefault(pathobj);
+    if (pathbytes == NULL)
         return NULL;
+    pathname = PyBytes_AS_STRING(pathbytes);
 
     flags.cf_flags = 0;
     mod = PyParser_ASTFromFile(fp, pathname, NULL,
@@ -1169,6 +1170,7 @@
     if (mod) {
         co = PyAST_Compile(mod, pathname, NULL, arena);
     }
+    Py_DECREF(pathbytes);
     PyArena_Free(arena);
     return co;
 }


More information about the Python-checkins mailing list