]> granicus.if.org Git - python/commitdiff
Fix import of frozen package submodules to use Unicode. Fixes test_frozen.
authorGuido van Rossum <guido@python.org>
Mon, 23 Jul 2007 03:16:50 +0000 (03:16 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 23 Jul 2007 03:16:50 +0000 (03:16 +0000)
Python/import.c

index cd76fa265b45633ed12f1584db4bf1d17dba41a3..25c768fea45cd7f4a04e9ca8417aa3bc53266741 100644 (file)
@@ -1188,15 +1188,16 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
                Py_DECREF(meta_path);
        }
 
-       if (path != NULL && PyString_Check(path)) {
+       if (path != NULL && PyUnicode_Check(path)) {
                /* The only type of submodule allowed inside a "frozen"
                   package are other frozen modules or packages. */
-               if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
+               char *p = PyUnicode_AsString(path);
+               if (strlen(p) + 1 + strlen(name) >= (size_t)buflen) {
                        PyErr_SetString(PyExc_ImportError,
                                        "full frozen module name too long");
                        return NULL;
                }
-               strcpy(buf, PyString_AsString(path));
+               strcpy(buf, p);
                strcat(buf, ".");
                strcat(buf, name);
                strcpy(name, buf);