[Python-Dev] ImportWarning flood

Nick Coghlan ncoghlan at gmail.com
Mon Jun 26 12:27:03 CEST 2006


Guido van Rossum wrote:
> On 6/24/06, Jean-Paul Calderone <exarkun at divmod.com> wrote:
>>> Actually, your application *was* pretty close to being broken a few
>>> weeks ago, when Guido wanted to drop the requirement that a package
>>> must contain an __init__ file. In that case, "import math" would have
>>> imported the directory, and given you an empty package.
>> But this change was *not* made, and afaict it is not going to be made.
> 
> Correct. We'll stick with the warning. (At least until Py3k but most
> likely also in Py3k.)

Perhaps ImportWarning should default to being ignored, the same way 
PendingDeprecationWarning does?

Then -Wd would become 'the one obvious way' to debug import problems, since it 
would switch ImportWarning on without drowning you in a flood of import 
diagnostics the way -v can do.

Import Errors could even point you in the right direction:

 >>> import mypackage.foo
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
ImportError: No module named mypackage.foo
     Diagnostic import warnings can be enabled with -Wd

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list