summaryrefslogtreecommitdiff
path: root/astroid/interpreter
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2022-05-31 04:32:00 -0400
committerGitHub <noreply@github.com>2022-05-31 10:32:00 +0200
commit1ccb1c455b71bcf453253d996e3739f5153f2774 (patch)
treea132b4ec908d80a95cabcd81bdea31b40d1d214d /astroid/interpreter
parent2ff48000b6896e17ffe7ca04722cf6a61b7a27cb (diff)
downloadastroid-git-1ccb1c455b71bcf453253d996e3739f5153f2774.tar.gz
Special case `__main__` in `is_namespace()` (#1579)
Diffstat (limited to 'astroid/interpreter')
-rw-r--r--astroid/interpreter/_import/util.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/astroid/interpreter/_import/util.py b/astroid/interpreter/_import/util.py
index 3de921b8..5db1702d 100644
--- a/astroid/interpreter/_import/util.py
+++ b/astroid/interpreter/_import/util.py
@@ -34,8 +34,8 @@ def is_namespace(modname: str) -> bool:
working_modname, path=last_submodule_search_locations
)
except ValueError:
- # executed .pth files may not have __spec__
- return True
+ # Assume it's a .pth file, unless it's __main__
+ return modname != "__main__"
except KeyError:
# Intermediate steps might raise KeyErrors
# https://github.com/python/cpython/issues/93334