@@ -920,10 +920,10 @@ def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True)
920
920
# success, no need to try any more versions of this project
921
921
break
922
922
923
- distributions = list (distributions )
924
- distributions .sort ()
923
+ sorted_distributions = list (distributions )
924
+ sorted_distributions .sort ()
925
925
926
- return distributions , error_info
926
+ return sorted_distributions , error_info
927
927
928
928
def require (self , * requirements ):
929
929
"""Ensure that distributions matching `requirements` are activated
@@ -1635,7 +1635,7 @@ def _validate_resource_path(path):
1635
1635
)
1636
1636
1637
1637
def _get (self , path ) -> bytes :
1638
- if hasattr (self .loader , 'get_data' ):
1638
+ if hasattr (self .loader , 'get_data' ) and self . loader :
1639
1639
return self .loader .get_data (path )
1640
1640
raise NotImplementedError (
1641
1641
"Can't perform this operation for loaders without 'get_data()'"
@@ -2490,8 +2490,9 @@ def resolve(self):
2490
2490
raise ImportError (str (exc )) from exc
2491
2491
2492
2492
def require (self , env = None , installer = None ):
2493
- if self .extras and not self .dist :
2494
- raise UnknownExtra ("Can't require() without a distribution" , self )
2493
+ if not self .dist :
2494
+ error_cls = UnknownExtra if self .extras else AttributeError
2495
+ raise error_cls ("Can't require() without a distribution" , self )
2495
2496
2496
2497
# Get the requirements for this entry point with all its extras and
2497
2498
# then resolve them. We have to pass `extras` along when resolving so
@@ -2557,11 +2558,11 @@ def parse_group(cls, group, lines, dist=None):
2557
2558
def parse_map (cls , data , dist = None ):
2558
2559
"""Parse a map of entry point groups"""
2559
2560
if isinstance (data , dict ):
2560
- data = data .items ()
2561
+ _data = data .items ()
2561
2562
else :
2562
- data = split_sections (data )
2563
+ _data = split_sections (data )
2563
2564
maps = {}
2564
- for group , lines in data :
2565
+ for group , lines in _data :
2565
2566
if group is None :
2566
2567
if not lines :
2567
2568
continue
@@ -2823,7 +2824,7 @@ def activate(self, path=None, replace=False):
2823
2824
if path is None :
2824
2825
path = sys .path
2825
2826
self .insert_on (path , replace = replace )
2826
- if path is sys .path :
2827
+ if path is sys .path and self . location is not None :
2827
2828
fixup_namespace_packages (self .location )
2828
2829
for pkg in self ._get_metadata ('namespace_packages.txt' ):
2829
2830
if pkg in sys .modules :
@@ -2891,15 +2892,13 @@ def load_entry_point(self, group, name):
2891
2892
2892
2893
def get_entry_map (self , group = None ):
2893
2894
"""Return the entry point map for `group`, or the full entry map"""
2894
- try :
2895
- ep_map = self ._ep_map
2896
- except AttributeError :
2897
- ep_map = self ._ep_map = EntryPoint .parse_map (
2895
+ if not hasattr (self , "_ep_map" ):
2896
+ self ._ep_map = EntryPoint .parse_map (
2898
2897
self ._get_metadata ('entry_points.txt' ), self
2899
2898
)
2900
2899
if group is not None :
2901
- return ep_map .get (group , {})
2902
- return ep_map
2900
+ return self . _ep_map .get (group , {})
2901
+ return self . _ep_map
2903
2902
2904
2903
def get_entry_info (self , group , name ):
2905
2904
"""Return the EntryPoint object for `group`+`name`, or ``None``"""
0 commit comments