STINNER Victor <[email protected]> added the comment:
> I suggest also ignoring ENOTDIR and EISDIR. Not sure about EACCES.
We should maybe mimick the io module:
>>> open('Lib')
IsADirectoryError: [Errno 21] Is a directory: 'Lib'
In the io module, opening a directory raises an exception. In the import
machinery, an explicit check is done (stat+ISDIR) before opening the file. The
file is ignored if it is a directory. We can maybe remove the test before
opening the file, and handle IsADirectoryError exception instead.
--
I don't think that fopen() can fails with ENOTDIR. rmdir() can fail with
ENOTDIR.
--
For EACCES: Python ignores currently these errors. I was already surprised by
this behaviour. My use case: I have two users (haypo and fusil). I "installed"
a module of haypo user into /usr/lib/python... using symlink, but fusil doesn't
have access to /home/haypo. When fusil tries to load a module, import fails
without any warning or error.
Fail with an error is maybe not a good idea because it's not because a
directory of sys.path cannot be read, than the import will fail. The module can
be found in another (accessible) directory.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13192>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com