Index: Python/import.c =================================================================== --- Python/import.c (revision 45732) +++ Python/import.c (working copy) @@ -1270,11 +1270,18 @@ and there's an __init__ module in that directory */ #ifdef HAVE_STAT if (stat(buf, &statbuf) == 0 && /* it exists */ - S_ISDIR(statbuf.st_mode) && /* it's a directory */ - find_init_module(buf) && /* it has __init__.py */ - case_ok(buf, len, namelen, name)) { /* and case matches */ - Py_XDECREF(copy); - return &fd_package; + S_ISDIR(statbuf.st_mode)) { /* it's a directory */ + if (find_init_module(buf) && /* it has __init__.py */ + case_ok(buf, len, namelen, name)) { /* and case matches */ + Py_XDECREF(copy); + return &fd_package; + } + else { + char warnstr[500]; + sprintf(warnstr, "Not importing directory " + "'%.450s': missing __init__.py", buf); + PyErr_Warn(PyExc_ImportWarning, warnstr); + } } #else /* XXX How are you going to test for directories? */ Index: Python/exceptions.c =================================================================== --- Python/exceptions.c (revision 45732) +++ Python/exceptions.c (working copy) @@ -1647,6 +1647,8 @@ "Base class for warnings about constructs that will change semantically " "in the future."); +PyDoc_STRVAR(ImportWarning__doc__, +"Base class for warnings about probable mistakes in module imports"); /* module global functions */ @@ -1719,6 +1721,7 @@ PyObject *PyExc_OverflowWarning; PyObject *PyExc_RuntimeWarning; PyObject *PyExc_FutureWarning; +PyObject *PyExc_ImportWarning; @@ -1818,6 +1821,8 @@ RuntimeWarning__doc__}, {"FutureWarning", &PyExc_FutureWarning, &PyExc_Warning, FutureWarning__doc__}, + {"ImportWarning", &PyExc_ImportWarning, &PyExc_Warning, + ImportWarning__doc__}, /* Sentinel */ {NULL} }; Index: Include/pyerrors.h =================================================================== --- Include/pyerrors.h (revision 45732) +++ Include/pyerrors.h (working copy) @@ -108,6 +108,7 @@ PyAPI_DATA(PyObject *) PyExc_OverflowWarning; PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; PyAPI_DATA(PyObject *) PyExc_FutureWarning; +PyAPI_DATA(PyObject *) PyExc_ImportWarning; /* Convenience functions */