diff -r a5e621c8dd44 Lib/imp.py --- a/Lib/imp.py Wed May 30 22:17:30 2012 +1000 +++ b/Lib/imp.py Fri Jun 01 12:04:48 2012 +0100 @@ -147,7 +147,7 @@ break else: raise ValueError('{!r} is not a package'.format(path)) - return _bootstrap.SourceFileLoader(name, path).load_module(name) + return _bootstrap.SourceFileLoader(name, path, True).load_module(name) # XXX deprecate diff -r a5e621c8dd44 Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Wed May 30 22:17:30 2012 +1000 +++ b/Lib/importlib/_bootstrap.py Fri Jun 01 12:04:48 2012 +0100 @@ -762,11 +762,16 @@ """Base file loader class which implements the loader protocol methods that require file system usage.""" - def __init__(self, fullname, path): + def __init__(self, fullname, path, is_package=False): """Cache the module name and the path to the file found by the finder.""" self.name = fullname self.path = path + self._is_package = is_package + + @_check_name + def is_package(self, fullname): + return self._is_package @_check_name def load_module(self, fullname): @@ -1111,7 +1116,7 @@ init_filename = '__init__' + suffix full_path = _path_join(base_path, init_filename) if _path_isfile(full_path): - return (loader(fullname, full_path), [base_path]) + return (loader(fullname, full_path, True), [base_path]) else: # A namespace package, return the path return (None, [base_path]) diff -r a5e621c8dd44 Lib/importlib/test/source/test_file_loader.py --- a/Lib/importlib/test/source/test_file_loader.py Wed May 30 22:17:30 2012 +1000 +++ b/Lib/importlib/test/source/test_file_loader.py Fri Jun 01 12:04:48 2012 +0100 @@ -73,7 +73,7 @@ def test_package(self): with source_util.create_modules('_pkg.__init__') as mapping: loader = _bootstrap.SourceFileLoader('_pkg', - mapping['_pkg.__init__']) + mapping['_pkg.__init__'], True) module = loader.load_module('_pkg') self.assertTrue('_pkg' in sys.modules) check = {'__name__': '_pkg', '__file__': mapping['_pkg.__init__'], diff -r a5e621c8dd44 Python/importlib.h Binary file Python/importlib.h has changed