Where is the c source code of the import mechanism that ignores invalid directory?

Shiyao Ma i at introo.me
Tue Jul 21 17:35:19 CEST 2015


It looks to me that the import system of Python will ignore invalid
directories and cache the result in memory.

For example, the following code:
paste here: https://bpaste.net/show/b144deb42620

#!/usr/bin/env python3
import sysimport osimport shutil
sys.path.append("./test")shutil.rmtree("./test", ignore_errors=True)
    import fooexcept ImportError:
    with open("./test/foo.py", "w") as f:

    import foo

the second import foo will fail even though it's there. This is because
when doing the first import foo, the directory .test doesn't exist, and
Python ignores that directory forever.

I am interested in the c side implementation of this "ignoring" part.

Any body help me to pinpoint the exact c source location?



吾輩は猫である。ホームーページはhttps://introo.me <http://introo.me>。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150721/950d5419/attachment.html>

More information about the Python-list mailing list