[Python-checkins] r82688 - python/branches/import_unicode/Python/import.c
victor.stinner
python-checkins at python.org
Fri Jul 9 01:32:46 CEST 2010
Author: victor.stinner
Date: Fri Jul 9 01:32:46 2010
New Revision: 82688
Log:
parse_source_module() uses object
not char*
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:32:46 2010
@@ -1141,15 +1141,22 @@
/* Parse a source file and return the corresponding code object */
static PyCodeObject *
-parse_source_module(const char *pathname, FILE *fp)
+parse_source_module(PyObject *pathobj, FILE *fp)
{
PyCodeObject *co = NULL;
mod_ty mod;
PyCompilerFlags flags;
+ char *pathname;
+
PyArena *arena = PyArena_New();
if (arena == NULL)
return NULL;
+ /* FIXME: use PyUnicode_EncodeFSDefault() */
+ pathname = _PyUnicode_AsString(pathobj);
+ if (pathname == NULL)
+ return NULL;
+
flags.cf_flags = 0;
mod = PyParser_ASTFromFile(fp, pathname, NULL,
Py_file_input, 0, 0, &flags,
@@ -1324,8 +1331,10 @@
PyCodeObject *co;
PyObject *m;
- /* FIXME: don't use _PyUnicode_AsString */
+ /* FIXME: use PyUnicode_EncodeFSDefault() */
pathname = _PyUnicode_AsString(pathobj);
+ if (pathname == NULL)
+ return NULL;
if (fstat(fileno(fp), &st) != 0) {
PyErr_Format(PyExc_RuntimeError,
@@ -1378,7 +1387,7 @@
name, (PyObject *)co, cpathobj, cpathobj);
}
else {
- co = parse_source_module(pathname, fp);
+ co = parse_source_module(pathobj, fp);
if (co == NULL) {
Py_XDECREF(cpathobj);
return NULL;
@@ -1442,7 +1451,7 @@
return NULL;
}
- /* FIXME: don't use _PyUnicode_AsString */
+ /* FIXME: use PyUnicode_EncodeFSDefault() */
py = _PyUnicode_AsString(pyobj);
if (py == NULL)
return NULL;
@@ -1476,12 +1485,8 @@
char buf[MAXPATHLEN+1];
FILE *fp = NULL;
struct filedescr *fdp;
- char *pathname;
PyObject *bufobj;
- /* FIXME: don't use _PyUnicode_AsString */
- pathname = _PyUnicode_AsString(pathobj);
-
m = PyImport_AddModule(name);
if (m == NULL)
return NULL;
More information about the Python-checkins
mailing list