File tree 2 files changed +3
-2
lines changed
astroid/interpreter/_import
2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ def is_namespace(modname: str) -> bool:
34
34
working_modname , path = last_submodule_search_locations
35
35
)
36
36
except ValueError :
37
- # executed .pth files may not have __spec__
38
- return True
37
+ # Assume it's a .pth file, unless it's __main__
38
+ return modname != "__main__"
39
39
except KeyError :
40
40
# Intermediate steps might raise KeyErrors
41
41
# https://github.com/python/cpython/issues/93334
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ def test_submodule_homonym_with_non_module(self) -> None:
127
127
128
128
def test_module_is_not_namespace (self ) -> None :
129
129
self .assertFalse (util .is_namespace ("tests.testdata.python3.data.all" ))
130
+ self .assertFalse (util .is_namespace ("__main__" ))
130
131
131
132
def test_implicit_namespace_package (self ) -> None :
132
133
data_dir = os .path .dirname (resources .find ("data/namespace_pep_420" ))
You can’t perform that action at this time.
0 commit comments