diff Python/exceptions.c @ 38018:b5e7d5b3c442 legacy-trunk

- 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.
author Thomas Wouters <thomas@python.org>
date Thu, 27 Apr 2006 23:13:20 +0000
parents 9b22d8b7bcaa
children e2ef60fec3da
line wrap: on
line diff
--- a/Python/exceptions.c	Thu Apr 27 22:53:05 2006 +0000
+++ b/Python/exceptions.c	Thu Apr 27 23:13:20 2006 +0000
@@ -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}
 };