Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 42898:0020bc784c76
Some changes in preparation of stricter rules about mixing str and bytes.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 27 Aug 2007 15:02:28 +0000 |
| parents | ed1594a16bdb |
| children | 981ecc526703 |
line wrap: on
line diff
--- a/Python/import.c Mon Aug 27 11:33:42 2007 +0000 +++ b/Python/import.c Mon Aug 27 15:02:28 2007 +0000 @@ -1247,8 +1247,15 @@ 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 */
