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

Function _setup

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

Source from the content-addressed store, hash-verified

591
592
593def _setup(namespace: Mapping[str, Any]) -> None:
594 global raw_input
595 if raw_input is not None:
596 return # don't run _setup twice
597
598 try:
599 f_in = sys.stdin.fileno()
600 f_out = sys.stdout.fileno()
601 except (AttributeError, ValueError):
602 return
603 if not os.isatty(f_in) or not os.isatty(f_out):
604 return
605
606 _wrapper.f_in = f_in
607 _wrapper.f_out = f_out
608
609 # set up namespace in rlcompleter, which requires it to be a bona fide dict
610 if not isinstance(namespace, dict):
611 namespace = dict(namespace)
612 _wrapper.config.module_completer = ModuleCompleter(namespace)
613 use_basic_completer = (
614 not sys.flags.ignore_environment
615 and os.getenv("PYTHON_BASIC_COMPLETER")
616 )
617 completer_cls = RLCompleter if use_basic_completer else FancyCompleter
618 _wrapper.config.readline_completer = completer_cls(namespace).complete
619
620 # this is not really what readline.c does. Better than nothing I guess
621 import builtins
622 raw_input = builtins.input
623 builtins.input = _wrapper.input
624
625
626raw_input: Callable[[object], str] | None = None

Callers 1

Calls 3

ModuleCompleterClass · 0.85
filenoMethod · 0.45
isattyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…