diff --git a/Lib/site.py b/Lib/site.py --- a/Lib/site.py +++ b/Lib/site.py @@ -383,18 +383,26 @@ def enablerlcompleter(): import atexit try: import readline import rlcompleter except ImportError: return # Reading the initialization (config) file may not be enough to set a - # completion key, so we set one first and then read the file - if 'libedit' in getattr(readline, '__doc__', ''): + # completion key, so we set one first and then read the file. + # + # On MacOS X the readline module can be implemented using the libedit + # library instead of GNU readline. See msg123703 in issue 5845 for more + # information. + # + # On Windows the pyreadline module's __doc__ attribute is None. + # See issue 18852. + readline_doc = getattr(readline, '__doc__', '') + if readline_doc is not None and 'libedit' in readline_doc: readline.parse_and_bind('bind ^I rl_complete') else: readline.parse_and_bind('tab: complete') try: readline.read_init_file() except OSError: # An OSError here could have many causes, but the most likely one