summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-09 18:53:47 (GMT)
committerGuido van Rossum <guido@python.org>1997-09-09 18:53:47 (GMT)
commita86f77d4dd5dc6dc8062c8645a2f6e5fbba3767d (patch)
tree121918d57ed942cc13e42c5dcee1489d9b5b7def /Python
parentb95901ec2e9bed764bffcd80e52f0771d9b9cb9e (diff)
downloadcpython-a86f77d4dd5dc6dc8062c8645a2f6e5fbba3767d.zip
cpython-a86f77d4dd5dc6dc8062c8645a2f6e5fbba3767d.tar.gz
cpython-a86f77d4dd5dc6dc8062c8645a2f6e5fbba3767d.tar.bz2
Crrected a flow control error that caused the wrong error message when
load-module() didn't find a built-in or frozen module. Also got rid of is_frozen(), which duplicated the functionality of find_frozen()!=NULL.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/Python/import.c b/Python/import.c
index 3bf205f..2192afa 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -546,6 +546,7 @@ load_source_module(name, pathname, fp)
static PyObject *load_module Py_PROTO((char *, FILE *, char *, int));
static struct filedescr *find_module Py_PROTO((char *, PyObject *,
char *, int, FILE **));
+static struct _frozen *find_frozen Py_PROTO((char *name));
/* Load a package and return its module object WITH INCREMENTED
REFERENCE COUNT */
@@ -622,22 +623,6 @@ is_builtin(name)
return 0;
}
-/* Helper to test for frozen module */
-
-static int
-is_frozen(name)
- char *name;
-{
- struct _frozen *p;
- for (p = PyImport_FrozenModules; ; p++) {
- if (p->name == NULL)
- break;
- if (strcmp(p->name, name) == 0)
- return 1;
- }
- return 0;
-}
-
/* Search the path (default sys.path) for a module. Return the
corresponding filedescr struct, and (via return arguments) the
@@ -666,7 +651,7 @@ find_module(name, path, buf, buflen, p_fp)
static struct filedescr fd = {"", "", C_BUILTIN};
return &fd;
}
- if (is_frozen(name)) {
+ if (find_frozen(name) != NULL) {
static struct filedescr fd = {"", "", PY_FROZEN};
return &fd;
}
@@ -837,14 +822,14 @@ load_module(name, fp, buf, type)
else
err = PyImport_ImportFrozenModule(name);
if (err < 0)
- goto failure;
+ return NULL;
if (err == 0) {
PyErr_Format(PyExc_ImportError,
"Purported %s module %.200s not found",
type == C_BUILTIN ?
"builtin" : "frozen",
name);
- goto failure;
+ return NULL;
}
modules = PyImport_GetModuleDict();
m = PyDict_GetItemString(modules, name);
@@ -855,13 +840,12 @@ load_module(name, fp, buf, type)
type == C_BUILTIN ?
"builtin" : "frozen",
name);
- goto failure;
+ return NULL;
}
Py_INCREF(m);
break;
default:
- failure:
PyErr_Format(PyExc_ImportError,
"Don't know how to import %.200s (type code %d)",
name, type);
@@ -1636,7 +1620,7 @@ imp_is_frozen(self, args)
char *name;
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
- return PyInt_FromLong(is_frozen(name));
+ return PyInt_FromLong(find_frozen(name) != NULL);
}
static FILE *