@@ -1636,7 +1636,7 @@ def _validate_resource_path(path):
1636
1636
)
1637
1637
1638
1638
def _get (self , path ) -> bytes :
1639
- if self . loader and hasattr (self .loader , 'get_data' ):
1639
+ if hasattr (self .loader , 'get_data' ) and self . loader :
1640
1640
return self .loader .get_data (path )
1641
1641
raise NotImplementedError (
1642
1642
"Can't perform this operation for loaders without 'get_data()'"
@@ -2493,7 +2493,8 @@ def resolve(self):
2493
2493
2494
2494
def require (self , env = None , installer = None ):
2495
2495
if not self .dist :
2496
- raise UnknownExtra ("Can't require() without a distribution" , self )
2496
+ error_cls = UnknownExtra if self .extras else AttributeError
2497
+ raise error_cls ("Can't require() without a distribution" , self )
2497
2498
2498
2499
# Get the requirements for this entry point with all its extras and
2499
2500
# then resolve them. We have to pass `extras` along when resolving so
@@ -2825,7 +2826,7 @@ def activate(self, path=None, replace=False):
2825
2826
if path is None :
2826
2827
path = sys .path
2827
2828
self .insert_on (path , replace = replace )
2828
- if path is sys .path and self . location :
2829
+ if path is sys .path :
2829
2830
fixup_namespace_packages (self .location )
2830
2831
for pkg in self ._get_metadata ('namespace_packages.txt' ):
2831
2832
if pkg in sys .modules :
0 commit comments