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?
12
12
=============================
13
13
Release date: TBA
14
14
15
+ * Fixed crash in ``ExplicitNamespacePackageFinder`` involving ``_SixMetaPathImporter``.
16
+
17
+ Closes #1708
18
+
15
19
* Fix unhandled `FutureWarning` from pandas import in cython modules
16
20
17
21
Closes #1717
Original file line number Diff line number Diff line change @@ -72,7 +72,8 @@ def is_namespace(modname: str) -> bool:
72
72
if found_spec and found_spec .submodule_search_locations :
73
73
last_submodule_search_locations = found_spec .submodule_search_locations
74
74
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 7
7
types-python-dateutil
8
8
six
9
9
types-six
10
+ urllib3
Original file line number Diff line number Diff line change 17
17
from xml import etree
18
18
from xml .etree import ElementTree
19
19
20
+ import pytest
20
21
from pytest import CaptureFixture , LogCaptureFixture
21
22
22
23
import astroid
25
26
26
27
from . import resources
27
28
29
+ try :
30
+ import urllib3 # pylint: disable=unused-import
31
+
32
+ HAS_URLLIB3 = True
33
+ except ImportError :
34
+ HAS_URLLIB3 = False
35
+
28
36
29
37
def _get_file_from_object (obj ) -> str :
30
38
return modutils ._path_from_filename (obj .__file__ )
@@ -439,5 +447,14 @@ def test_is_module_name_part_of_extension_package_whitelist_success(self) -> Non
439
447
)
440
448
441
449
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
+
442
459
if __name__ == "__main__" :
443
460
unittest .main ()
You can’t perform that action at this time.
0 commit comments