[New-bugs-announce] [issue5376] Wrong ImportError message if module is not readable

STINNER Victor report at bugs.python.org
Thu Feb 26 16:56:33 CET 2009


New submission from STINNER Victor <victor.stinner at haypocalc.com>:

__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
------------------------------

----------
components: Interpreter Core
files: test.tar.gz
messages: 82766
nosy: haypo
severity: normal
status: open
title: Wrong ImportError message if module is not readable
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file13190/test.tar.gz

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5376>
_______________________________________


More information about the New-bugs-announce mailing list