diff options
author | Thomas Wouters <thomas@python.org> | 2006-04-21 10:40:58 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-04-21 10:40:58 (GMT) |
commit | 49fd7fa4431da299196d74087df4a04f99f9c46f (patch) | |
tree | 35ace5fe78d3d52c7a9ab356ab9f6dbf8d4b71f4 /Python/import.c | |
parent | 9ada3d6e29d5165dadacbe6be07bcd35cfbef59d (diff) | |
download | cpython-49fd7fa4431da299196d74087df4a04f99f9c46f.zip cpython-49fd7fa4431da299196d74087df4a04f99f9c46f.tar.gz cpython-49fd7fa4431da299196d74087df4a04f99f9c46f.tar.bz2 |
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
number of tests, all because of the codecs/_multibytecodecs issue described
here (it's not a Py3K issue, just something Py3K discovers):
http://mail.python.org/pipermail/python-dev/2006-April/064051.html
Hye-Shik Chang promised to look for a fix, so no need to fix it here. The
tests that are expected to break are:
test_codecencodings_cn
test_codecencodings_hk
test_codecencodings_jp
test_codecencodings_kr
test_codecencodings_tw
test_codecs
test_multibytecodec
This merge fixes an actual test failure (test_weakref) in this branch,
though, so I believe merging is the right thing to do anyway.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c index b64594d..daae15f 100644 --- a/Python/import.c +++ b/Python/import.c @@ -17,6 +17,9 @@ #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#ifdef __cplusplus +extern "C" { +#endif extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */ @@ -40,6 +43,7 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *); Python 1.5: 20121 Python 1.5.1: 20121 Python 1.5.2: 20121 + Python 1.6: 50428 Python 2.0: 50823 Python 2.0.1: 50823 Python 2.1: 60202 @@ -1217,12 +1221,12 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf, #endif if (!PyString_Check(v)) continue; - len = PyString_Size(v); + len = PyString_GET_SIZE(v); if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) { Py_XDECREF(copy); continue; /* Too long */ } - strcpy(buf, PyString_AsString(v)); + strcpy(buf, PyString_AS_STRING(v)); if (strlen(buf) != len) { Py_XDECREF(copy); continue; /* v contains '\0' */ @@ -1934,6 +1938,16 @@ import_module_level(char *name, PyObject *globals, PyObject *locals, } tail = next; } + if (tail == Py_None) { + /* If tail is Py_None, both get_parent and load_next found + an empty module name: someone called __import__("") or + doctored faulty bytecode */ + Py_DECREF(tail); + Py_DECREF(head); + PyErr_SetString(PyExc_ValueError, + "Empty module name"); + return NULL; + } if (fromlist != NULL) { if (fromlist == Py_None || !PyObject_IsTrue(fromlist)) @@ -2094,7 +2108,8 @@ load_next(PyObject *mod, PyObject *altmod, char **p_name, char *buf, PyObject *result; if (strlen(name) == 0) { - /* empty module name only happens in 'from . import' */ + /* completely empty module name should only happen in + 'from . import' (or '__import__("")')*/ Py_INCREF(mod); *p_name = NULL; return mod; @@ -2936,3 +2951,7 @@ PyImport_AppendInittab(char *name, void (*initfunc)(void)) return PyImport_ExtendInittab(newtab); } + +#ifdef __cplusplus +} +#endif |