Guido van Rossum added the comment: Hey Brett,
Sorry for reopening this issue. I am confused by the spec for ModuleNotFoundError. Look at this (in a pretty recent repo): $ ./python.exe Python 3.4.0a0 (default:8f22e03f5f07, Jun 27 2013, 08:49:16) [GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin Type "help", "copyright", "credits" or "license" for more information. [1] >>> import bogus Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'bogus' [2] >>> from re import bogus Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: cannot import name bogus [3] >>> import re.bogus Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1553, in _find_and_load_unlocked AttributeError: 'module' object has no attribute '__path__' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 're.bogus'; re is not a package Given that it knows that re is not a package, I would have expected [2] not to raise ModuleNotFoundError, because there is no way that bogus could be a package. OTOH, I would have expected [3] to raise ModuleNotFoundError, since this syntax implies that bogus is a submodule. But perhaps I am missing something and I need to look at the distinction differently? Sadly the docs don't really help me; they claim to explain why I get ModuleNotFoundError in [2], but the motivation "as the specific attribute being requested cannot be known a priori to be a module or some other type of object" seems wrong, given that [3] proves it *does* know. (Aside, it's also odd that bogus is quoted in the error message for [1] and [3] but not for [2] -- in fact the phrasing of [2] compared to [1] seems arbitrarily different, both seem to tell me exactly the same thing.) ---------- nosy: +gvanrossum status: closed -> open _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15767> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com