Re: [Python-Dev] Clarifications for import PEPs (302 and 328)
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."
On 4/23/07, Phillip J. Eby <pje@telecommunity.com> wrote:
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"?
Not if you read the PEP. It doesn't explicitly say what should happen. I want to standardize on raising ImportError. The PEP itself has two ways of signaling an error; find_module() returns None instead of raising an error to signal it can't do something while path hooks raise ImportError. I just want to be as explicit as possible. -Brett
On 24/04/07, Brett Cannon <brett@python.org> wrote:
Not if you read the PEP. It doesn't explicitly say what should happen.
I want to standardize on raising ImportError. The PEP itself has two ways of signaling an error; find_module() returns None instead of raising an error to signal it can't do something while path hooks raise ImportError. I just want to be as explicit as possible.
I'm happy with that. As far as I remember, that was the original intention - and you're right, it should be made explicit. Paul.
participants (3)
-
Brett Cannon
-
Paul Moore
-
Phillip J. Eby