Gabriel Genellina <gagsl-...@yahoo.com.ar> added the comment: Looks like an optimization for the common case when directories aren't created "on the fly". Your proposal would slow down all imports (a typical sys.path actually contains a few nonexisting directories).
Quoting PEP302: The results of path hook checks are cached in sys.path_importer_cache, which is a dictionary mapping path entries to importer objects. The cache is checked before sys.path_hooks is scanned. If it is necessary to force a rescan of sys.path_hooks, it is possible to manually clear all or part of sys.path_importer_cache. So the problem is that some cached data is outdated. In this case, after creating a directory that might be listed in sys.path, you should clear the cached entries using either of these lines: sys.path_importer_cache.pop("/tmp/foobar", None) sys.path_importer_cache.clear() and then your test code succeeds. (I'd close the issue as 'invalid') ---------- nosy: +gagenellina _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6636> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com