Skip to content

Commit 6054748

Browse files
Fix namespace detection crash (#2949)
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
1 parent d4a7e63 commit 6054748

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Release date: TBA
7171

7272
Closes #2923
7373

74+
* Fix ``is_namespace()`` crash when search locations contain ``pathlib.Path`` objects.
75+
76+
Closes #2942
77+
7478
What's New in astroid 4.0.3?
7579
============================
7680
Release date: 2026-01-03

astroid/interpreter/_import/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ def is_namespace(modname: str) -> bool:
9595
# But immediately return False if we can detect we are in stdlib
9696
# or external lib (e.g site-packages)
9797
if any(
98-
any(location.startswith(lib_dir) for lib_dir in STD_AND_EXT_LIB_DIRS)
98+
any(
99+
str(location).startswith(lib_dir)
100+
for lib_dir in STD_AND_EXT_LIB_DIRS
101+
)
99102
for location in found_spec.submodule_search_locations
100103
):
101104
return False

0 commit comments

Comments
 (0)