This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong ImportError message if module is not readable
Type: Stage:
Components: Interpreter Core Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, vstinner
Priority: normal Keywords:

Created on 2009-02-26 15:56 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue5376.tar.gz vstinner, 2009-02-26 23:09
Messages (4)
msg82766 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-02-26 15:56
__import__() raises an ImportError "No module named ..." if the module 
file is not readable or module directory is not executable. The 
expected message is something like "Module named ... is not readable".

Directory tree for the test:
------------------------------
marge$ ls -lRF .
.:
drwxrwxrwx 2 haypo haypo 4096 2009-02-26 16:51 module/
-rw-rw-rw- 1 haypo haypo    9 2009-02-26 16:48 module2.py
-rw-r--r-- 1 haypo haypo  414 2009-02-26 16:50 test.py

./module:
-rw-r--r-- 1 haypo haypo 10 2009-02-26 16:45 __init__.py
------------------------------

Success with correct file permissions:
------------------------------
$ python test.py
__import__('/home/haypo/xxx/module') ...
PI = 3.14
__import__('/home/haypo/xxx/module2') ...
E = 2.72
------------------------------

Change module/ and module2.py permissions to 000 (no read, no write, 
no execute):
------------------------------
__import__('/home/haypo/xxx/module') ...
No module named /home/haypo/xxx/module
__import__('/home/haypo/xxx/module2') ...
No module named /home/haypo/xxx/module2
------------------------------
msg82785 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-02-26 23:09
Oops, my first .tar.gz doesn't create files in a subdirectory. New 
archive fixes that.
msg82786 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-02-26 23:18
Oooh, import by filename has been disabled in Python 2.6: see issue 
#1776.
msg85526 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-05 16:33
Since this is not supported anyway (and never was), closing as "won't fix".
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49626
2009-04-05 16:33:04georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg85526

resolution: wont fix
2009-02-26 23:18:20vstinnersetmessages: + msg82786
2009-02-26 23:09:37vstinnersetfiles: + issue5376.tar.gz
messages: + msg82785
2009-02-26 23:08:59vstinnersetfiles: - test.tar.gz
2009-02-26 15:56:32vstinnercreate