Skip to content

Commit b36972d

Browse files
committed
first steps: don't show help output for dunders we've grabbed from builtins
1 parent ac37b77 commit b36972d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/pydoc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,11 @@ def describe(thing):
17061706

17071707
def 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
17091714
parts = [part for part in path.split('.') if part]
17101715
module, n = None, 0
17111716
while n < len(parts):

0 commit comments

Comments
 (0)