File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed
astroid/interpreter/_import Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ What's New in astroid 2.12.3?
1212=============================
1313Release date: TBA
1414
15+ * Fixed crash in ``ExplicitNamespacePackageFinder`` involving ``_SixMetaPathImporter``.
16+
17+ Closes #1708
18+
1519* Fix unhandled `FutureWarning` from pandas import in cython modules
1620
1721 Closes #1717
Original file line number Diff line number Diff line change @@ -72,7 +72,8 @@ def is_namespace(modname: str) -> bool:
7272 if found_spec and found_spec .submodule_search_locations :
7373 last_submodule_search_locations = found_spec .submodule_search_locations
7474
75- if found_spec is None :
76- return False
77-
78- return found_spec .origin is None
75+ return (
76+ found_spec is not None
77+ and found_spec .submodule_search_locations is not None
78+ and found_spec .origin is None
79+ )
Original file line number Diff line number Diff line change 77types-python-dateutil
88six
99types-six
10+ urllib3
Original file line number Diff line number Diff line change 1717from xml import etree
1818from xml .etree import ElementTree
1919
20+ import pytest
2021from pytest import CaptureFixture , LogCaptureFixture
2122
2223import astroid
2526
2627from . import resources
2728
29+ try :
30+ import urllib3 # pylint: disable=unused-import
31+
32+ HAS_URLLIB3 = True
33+ except ImportError :
34+ HAS_URLLIB3 = False
35+
2836
2937def _get_file_from_object (obj ) -> str :
3038 return modutils ._path_from_filename (obj .__file__ )
@@ -439,5 +447,14 @@ def test_is_module_name_part_of_extension_package_whitelist_success(self) -> Non
439447 )
440448
441449
450+ @pytest .mark .skipif (not HAS_URLLIB3 , reason = "This test requires urllib3." )
451+ def test_file_info_from_modpath__SixMetaPathImporter () -> None :
452+ pytest .raises (
453+ ImportError ,
454+ modutils .file_info_from_modpath ,
455+ ["urllib3.packages.six.moves.http_client" ],
456+ )
457+
458+
442459if __name__ == "__main__" :
443460 unittest .main ()
You can’t perform that action at this time.
0 commit comments