Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13d7799

Browse files
committed
Fix import of frozen package submodules to use Unicode. Fixes test_frozen.
1 parent 3698746 commit 13d7799

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Python/import.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,15 +1188,16 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
11881188
Py_DECREF(meta_path);
11891189
}
11901190

1191-
if (path != NULL && PyString_Check(path)) {
1191+
if (path != NULL && PyUnicode_Check(path)) {
11921192
/* The only type of submodule allowed inside a "frozen"
11931193
package are other frozen modules or packages. */
1194-
if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
1194+
char *p = PyUnicode_AsString(path);
1195+
if (strlen(p) + 1 + strlen(name) >= (size_t)buflen) {
11951196
PyErr_SetString(PyExc_ImportError,
11961197
"full frozen module name too long");
11971198
return NULL;
11981199
}
1199-
strcpy(buf, PyString_AsString(path));
1200+
strcpy(buf, p);
12001201
strcat(buf, ".");
12011202
strcat(buf, name);
12021203
strcpy(name, buf);

0 commit comments

Comments
 (0)