New submission from Barry A. Warsaw <ba...@python.org>: Along the lines of Issue32303 there's another inconsistency in namespace package metadata. Let's say I have a namespace package:
>>> importlib_resources.tests.data03.namespace <module 'importlib_resources.tests.data03.namespace' (namespace)> The package has no __file__ attribute, and it has a misleading __spec__.origin >>> importlib_resources.tests.data03.namespace.__spec__.origin 'namespace' >>> importlib_resources.tests.data03.namespace.__file__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'importlib_resources.tests.data03.namespace' has no attribute '__file__' This is especially bad because the documentation for __spec__.origin implies a correlation to __file__, and says: "Name of the place from which the module is loaded, e.g. “builtin” for built-in modules and the filename for modules loaded from source. Normally “origin” should be set, but it may be None (the default) which indicates it is unspecified." I don't particularly like that its origin is "namespace". That's an odd special case that's unhelpful to test against (what if you import a non-namespace package from the directory "namespace"?) What would break if __spec__.origin were (missing? or) None? ---------- messages: 308206 nosy: barry priority: normal severity: normal status: open title: Namespace packages have inconsistent __file__ and __spec__.origin versions: Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32305> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com