At 02:07 PM 4/26/2006 -0400, Phillip J. Eby wrote:
>          def find_module(self, fullname, path=None):
>              # Note: we ignore 'path' argument since it is only used via
>meta_path
>              subname = fullname.split(".")[-1]
>              if os.path.isdir(os.path.join(self.path, subname)):
>                  return self
>              path = [self.path]
>              try:
>                  file, filename, etc = imp.find_module(subname, path)
>              except ImportError:
>                  return None
>              return ImpLoader(fullname, file, filename, etc)

Feh.  The above won't properly handle the case where there *is* an __init__ 
module.  Trying again:

          def find_module(self, fullname, path=None):
              subname = fullname.split(".")[-1]
              path = [self.path]
              try:
                  file, filename, etc = imp.find_module(subname, path)
              except ImportError:
                  if os.path.isdir(os.path.join(self.path, subname)):
                      return self
                  else:
                      return None
              return ImpLoader(fullname, file, filename, etc)

There, that should only fall back to __init__-less handling if there's no 
foo.py or foo/__init__.py present.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to