New submission from Manuel Jacob:

Python 3.6.0a0 (default:6c6f7dff597b, Feb 16 2016, 01:24:51) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib
>>> importlib.__import__('array', globals(), locals(), level=1)
<module '.array' from 
'/home/manu/vcs/cpython/build/lib.linux-x86_64-3.6/array.cpython-36m-x86_64-linux-gnu.so'>
>>> __import__('array', globals(), locals(), level=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: attempted relative import with no known parent package

Instead of failing, importlib.__import__ returns a module with a wrong name.  
This happens with both built-in modules and pure python modules.  However it 
fails when replacing 'array' with 'time' (this seems to be related to whether 
the module is in Modules/Setup.dist).

----------
messages: 260338
nosy: brett.cannon, eric.snow, mjacob, ncoghlan
priority: normal
severity: normal
status: open
title: importlib.__import__ does not fail for invalid relative import
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26367>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to