1919if hasattr (readline , "_READLINE_LIBRARY_VERSION" ):
2020 is_editline = ("EditLine wrapper" in readline ._READLINE_LIBRARY_VERSION )
2121else :
22- is_editline = ( readline .__doc__ and "libedit" in readline . __doc__ )
22+ is_editline = readline .backend == "editline"
2323
2424
2525def setUpModule ():
@@ -145,6 +145,9 @@ def test_init(self):
145145 TERM = 'xterm-256color' )
146146 self .assertEqual (stdout , b'' )
147147
148+ def test_backend (self ):
149+ self .assertIn (readline .backend , ("readline" , "editline" ))
150+
148151 auto_history_script = """\
149152 import readline
150153readline.set_auto_history({})
@@ -171,7 +174,7 @@ def complete(text, state):
171174 if state == 0 and text == "$":
172175 return "$complete"
173176 return None
174- if "libedit" in getattr( readline, "__doc__", "") :
177+ if readline.backend == "editline" :
175178 readline.parse_and_bind(r'bind "\\ t" rl_complete')
176179 else:
177180 readline.parse_and_bind(r'"\\ t": complete')
@@ -198,7 +201,7 @@ def test_nonascii(self):
198201
199202 script = r"""import readline
200203
201- is_editline = readline.__doc__ and "libedit" in readline.__doc__
204+ is_editline = readline.backend == "editline"
202205inserted = "[\xEFnserted]"
203206macro = "|t\xEB[after]"
204207set_pre_input_hook = getattr(readline, "set_pre_input_hook", None)
0 commit comments