[Python-Dev] Clarifications for import PEPs (302 and 328)

Phillip J. Eby pje at telecommunity.com
Tue Apr 24 01:21:00 CEST 2007


At 03:16 PM 4/23/2007 -0700, Brett Cannon wrote:
>The PEP does not explicitly state how to signal that a loader cannot
>load a module it is asked to.  This could happen if someone called a
>loader without consulting its respective importer.  I would want to
>add something like:
>"""
>If the loader is unable to load the specified module and a specific
>exception is not raised in determining this, ImportError is raised.
>This may occur if a loader is called without first consulting an
>importer as to if the loader can load the specified module but the
>loader is aware of the fact it cannot fulfill the request made.
>"""

Okay, now I understand what you're trying to say, but I still don't 
understand what the purpose is.  I mean, what else would you do except 
raise an error?  I.e., isn't the actual contract "load the specified module 
or raise an exception of some kind"?

I mean, how about something like:

"If for any reason the loader can't load the requested module, it must 
raise an exception (such as an ImportError), or allow an existing exception 
to propagate out of the load_module() call."



More information about the Python-Dev mailing list