MCPcopy Index your code
hub / github.com/RustPython/RustPython / detach_readline

Method detach_readline

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

Source from the content-addressed store, hash-verified

2677
2678 @contextlib.contextmanager
2679 def detach_readline(self):
2680 # bpo-13886: When the readline module is loaded, PyOS_Readline() uses
2681 # the readline implementation. In some cases, the Python readline
2682 # callback rlhandler() is called by readline with a string without
2683 # non-ASCII characters.
2684 # Unlink readline temporarily from PyOS_Readline() for those tests,
2685 # since test_builtin is not intended to test
2686 # the readline module, but the builtins module.
2687 if "readline" in sys.modules:
2688 c = import_module("ctypes")
2689 fp_api = "PyOS_ReadlineFunctionPointer"
2690 prev_value = c.c_void_p.in_dll(c.pythonapi, fp_api).value
2691 c.c_void_p.in_dll(c.pythonapi, fp_api).value = None
2692 try:
2693 yield
2694 finally:
2695 c.c_void_p.in_dll(c.pythonapi, fp_api).value = prev_value
2696 else:
2697 yield
2698
2699 def test_input_tty(self):
2700 # Test input() functionality when wired to a tty

Callers 1

check_input_ttyMethod · 0.95

Calls 2

import_moduleFunction · 0.90
in_dllMethod · 0.45

Tested by

no test coverage detected