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

Function _setup

Lib/_pyrepl/readline.py:571–595  ·  view source on GitHub ↗
(namespace: Mapping[str, Any])

Source from the content-addressed store, hash-verified

569
570
571def _setup(namespace: Mapping[str, Any]) -> None:
572 global raw_input
573 if raw_input is not None:
574 return # don't run _setup twice
575
576 try:
577 f_in = sys.stdin.fileno()
578 f_out = sys.stdout.fileno()
579 except (AttributeError, ValueError):
580 return
581 if not os.isatty(f_in) or not os.isatty(f_out):
582 return
583
584 _wrapper.f_in = f_in
585 _wrapper.f_out = f_out
586
587 # set up namespace in rlcompleter, which requires it to be a bona fide dict
588 if not isinstance(namespace, dict):
589 namespace = dict(namespace)
590 _wrapper.config.readline_completer = RLCompleter(namespace).complete
591
592 # this is not really what readline.c does. Better than nothing I guess
593 import builtins
594 raw_input = builtins.input
595 builtins.input = _wrapper.input
596
597
598raw_input: Callable[[object], str] | None = None

Callers 1

Calls 3

isinstanceFunction · 0.85
filenoMethod · 0.45
isattyMethod · 0.45

Tested by

no test coverage detected