[New-bugs-announce] [issue13046] imp.find_module() should not find unimportable modules
Arfrever Frehtes Taifersar Arahesis
report at bugs.python.org
Sun Sep 25 21:03:51 CEST 2011
New submission from Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA at GMail.Com>:
imp.find_module() can find files, which cannot be imported. I suggest that imp.find_module() raise an exception in such cases.
$ cd /tmp
$ touch .something.py
$ python3.3
Python 3.3.0a0 (default:5e456e1a9e8c+, Sep 25 2011, 18:57:23)
[GCC 4.5.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import .something
File "<stdin>", line 1
import .something
^
SyntaxError: invalid syntax
>>> module = __import__(".something")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Empty module name
>>> import imp
>>> file, pathname, description = imp.find_module(".something")
>>> file, pathname, description
(<_io.TextIOWrapper name=4 mode='U' encoding='utf-8'>, '.something.py', ('.py', 'U', 1))
----------
components: Interpreter Core
messages: 144527
nosy: Arfrever
priority: normal
severity: normal
status: open
title: imp.find_module() should not find unimportable modules
versions: Python 2.7, Python 3.2, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13046>
_______________________________________
More information about the New-bugs-announce
mailing list