Author ggenellina
Recipients cemasoniv, ggenellina
Date 2009-08-05.00:05:55
SpamBayes Score 4.16006e-10
Marked as misclassified No
Message-id <1249430757.72.0.400608688419.issue6636@psf.upfronthosting.co.za>
In-reply-to
Content
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')
History
Date User Action Args
2009-08-05 00:05:58ggenellinasetrecipients: + ggenellina, cemasoniv
2009-08-05 00:05:57ggenellinasetmessageid: <1249430757.72.0.400608688419.issue6636@psf.upfronthosting.co.za>
2009-08-05 00:05:56ggenellinalinkissue6636 messages
2009-08-05 00:05:55ggenellinacreate