Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94297 > unrolled thread
| Started by | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| First post | 2015-07-21 17:16 +0100 |
| Last post | 2015-07-21 17:16 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Where is the c source code of the import mechanism that ignores invalid directory? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-21 17:16 +0100
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-07-21 17:16 +0100 |
| Subject | Re: Where is the c source code of the import mechanism that ignores invalid directory? |
| Message-ID | <mailman.819.1437495414.3674.python-list@python.org> |
On 21/07/2015 16:35, Shiyao Ma wrote:
> Hi,
>
> 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 sys
> import os
> import shutil
>
> sys.path.append("./test")
> shutil.rmtree("./test", ignore_errors=True)
>
> try:
> import foo
> except ImportError:
> os.mkdir("./test")
> with open("./test/foo.py", "w") as f:
> f.write("print(3)")
>
> 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?
>
> Thanks.
>
> --
>
> 吾輩は猫である。ホームーページはhttps://introo.me <http://introo.me>。
>
Start here https://hg.python.org/cpython/file/6629773fef63/Python/import.c
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Back to top | Article view | comp.lang.python
csiph-web