MCPcopy Index your code
hub / github.com/python/cpython / detach_readline

Method detach_readline

Lib/test/test_builtin.py:2729–2747  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2727
2728 @contextlib.contextmanager
2729 def detach_readline(self):
2730 # bpo-13886: When the readline module is loaded, PyOS_Readline() uses
2731 # the readline implementation. In some cases, the Python readline
2732 # callback rlhandler() is called by readline with a string without
2733 # non-ASCII characters.
2734 # Unlink readline temporarily from PyOS_Readline() for those tests,
2735 # since test_builtin is not intended to test
2736 # the readline module, but the builtins module.
2737 if "readline" in sys.modules:
2738 c = import_module("ctypes")
2739 fp_api = "PyOS_ReadlineFunctionPointer"
2740 prev_value = c.c_void_p.in_dll(c.pythonapi, fp_api).value
2741 c.c_void_p.in_dll(c.pythonapi, fp_api).value = None
2742 try:
2743 yield
2744 finally:
2745 c.c_void_p.in_dll(c.pythonapi, fp_api).value = prev_value
2746 else:
2747 yield
2748
2749 def test_input_tty(self):
2750 # Test input() functionality when wired to a tty

Callers 1

check_input_ttyMethod · 0.95

Calls 1

import_moduleFunction · 0.90

Tested by

no test coverage detected