summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-27 15:02:28 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-27 15:02:28 (GMT)
commita4b8d1de7c8bdacfa07f9545fcef81fee1c6601f (patch)
treec9a38216a2531622c7785490a8d66c34d9a32e2b /Python/import.c
parentddd25825c839cbae9dcc6c9a7c662d06ee113ca0 (diff)
downloadcpython-a4b8d1de7c8bdacfa07f9545fcef81fee1c6601f.zip
cpython-a4b8d1de7c8bdacfa07f9545fcef81fee1c6601f.tar.gz
cpython-a4b8d1de7c8bdacfa07f9545fcef81fee1c6601f.tar.bz2
Some changes in preparation of stricter rules about mixing str and bytes.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 8195bad..2ef6aec 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1247,8 +1247,15 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
Py_ssize_t size;
if (!v)
return NULL;
- if (PyObject_AsCharBuffer(v, &base, &size) < 0)
- return NULL;
+ if (PyUnicode_Check(v)) {
+ v = _PyUnicode_AsDefaultEncodedString(v, NULL);
+ if (v == NULL)
+ return NULL;
+ }
+ if (!PyString_Check(v))
+ continue;
+ base = PyString_AS_STRING(v);
+ size = PyString_GET_SIZE(v);
len = size;
if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
continue; /* Too long */