Skip to content

Commit d2f4627

Browse files
committed
replace allowlist with a check for module type
1 parent cac3a02 commit d2f4627

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

‎Lib/pydoc.py‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,12 +1715,11 @@ def locate(path, forceload=0):
17151715
return None
17161716
if (
17171717
_is_dunder_name(path)
1718-
and not isinstance(object, (type, type(__import__)))
1719-
and path not in SKIP_DUNDER_HELP
1718+
and not isinstance(object, (type, type(__import__), type(__future__)))
17201719
):
1721-
# if we're looking up a special variable and we don't find a class or a
1722-
# function, it's probably not what the user wanted (if it is, they can
1723-
# look up builtins.whatever)
1720+
# if we're looking up a special variable and we don't find a class,
1721+
# function, or module, it's probably not what the user wanted (if it
1722+
# is, they can look up builtins.whatever)
17241723
return None
17251724
return object
17261725

@@ -1847,12 +1846,6 @@ def _introdoc():
18471846
enter "q", "quit" or "exit".
18481847
''')
18491848

1850-
SKIP_DUNDER_HELP = frozenset({
1851-
'__future__',
1852-
'__hello__',
1853-
'__phello__',
1854-
})
1855-
18561849
def _is_dunder_name(x):
18571850
return isinstance(x, str) and x.isidentifier() and len(x) > 4 and x[:2] == x[-2:] == '__'
18581851

0 commit comments

Comments
 (0)