File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -1706,11 +1706,6 @@ def describe(thing):
17061706
17071707def locate (path , forceload = 0 ):
17081708 """Locate an object by name or dotted path, importing as necessary."""
1709- if re .match (r"^__\w+__$" , path ):
1710- # if we're looking up a special variable, don't grab the result from
1711- # the builtins module, because it's probably not what the user wanted
1712- # (if it is, they can look up builtins.whatever)
1713- return None
17141709 parts = [part for part in path .split ('.' ) if part ]
17151710 module , n = None , 0
17161711 while n < len (parts ):
@@ -1726,6 +1721,11 @@ def locate(path, forceload=0):
17261721 object = getattr (object , part )
17271722 except AttributeError :
17281723 return None
1724+ if re .match (r"^__\w+__$" , path ) and not isinstance (object , (type , type (__import__ ))):
1725+ # if we're looking up a special variable, don't grab the result from
1726+ # the builtins module, because it's probably not what the user wanted
1727+ # (if it is, they can look up builtins.whatever)
1728+ return None
17291729 return object
17301730
17311731# --------------------------------------- interactive interpreter interface
You can’t perform that action at this time.
0 commit comments