- Add new Warning class, ImportWarning

 - Warn-raise ImportWarning when importing would have picked up a directory
   as package, if only it'd had an __init__.py. This swaps two tests (for
   case-ness and __init__-ness), but case-test is not really more expensive,
   and it's not in a speed-critical section.

 - Test for the new warning by importing a common non-package directory on
   sys.path: site-packages

 - In regrtest.py, silence warnings generated by the build-environment
   because Modules/ (which is added to sys.path for Setup-created modules)
   has 'zlib' and '_ctypes' directories without __init__.py's.
diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt
index 9ed92d0..5fff7d9 100644
--- a/Lib/test/exception_hierarchy.txt
+++ b/Lib/test/exception_hierarchy.txt
@@ -44,3 +44,4 @@
            +-- UserWarning
            +-- FutureWarning
 	   +-- OverflowWarning [not generated by the interpreter]
+	   +-- ImportWarning
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 7db94aa..be06d9d 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -138,6 +138,12 @@
     warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
                             "<string>")
 
+# Ignore ImportWarnings that only occur in the source tree,
+# (because of modules with the same name as source-directories in Modules/)
+for mod in ("ctypes", "gzip", "test.test_zipimport", "test.test_zlib"):
+    warnings.filterwarnings(module=".*%s$" % (mod,),
+                            action="ignore", category=ImportWarning)
+
 # MacOSX (a.k.a. Darwin) has a default stack size that is too small
 # for deeply recursive regular expressions.  We see this as crashes in
 # the Python test suite when running test_re.py and test_sre.py.  The
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index a72b8bd..effba3c 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -205,3 +205,20 @@
     assert y is test.test_support, y.__name__
 
 test_import_name_binding()
+
+def test_import_initless_directory_warning():
+    import warnings
+    oldfilters = warnings.filters[:]
+    warnings.simplefilter('error', ImportWarning);
+    try:
+        # Just a random non-package directory we always expect to be
+        # somewhere in sys.path...
+        __import__("site-packages")
+    except ImportWarning:
+        pass
+    else:
+        raise AssertionError
+    finally:
+        warnings.filters = oldfilters
+
+test_import_initless_directory_warning()