MCPcopy Create free account
hub / github.com/bpython/bpython / __enter__

Method __enter__

bpython/curtsiesfrontend/repl.py:561–584  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

559 self._schedule_refresh(when=when)
560
561 def __enter__(self):
562 self.orig_stdout = sys.stdout
563 self.orig_stderr = sys.stderr
564 self.orig_stdin = sys.stdin
565 sys.stdout = self.stdout
566 sys.stderr = self.stderr
567 sys.stdin = self.stdin
568 self.orig_sigwinch_handler = signal.getsignal(signal.SIGWINCH)
569 self.orig_sigtstp_handler = signal.getsignal(signal.SIGTSTP)
570
571 if is_main_thread():
572 # This turns off resize detection and ctrl-z suspension.
573 signal.signal(signal.SIGWINCH, self.sigwinch_handler)
574 signal.signal(signal.SIGTSTP, self.sigtstp_handler)
575
576 self.orig_meta_path = sys.meta_path
577 if self.watcher:
578 meta_path = []
579 for finder in sys.meta_path:
580 meta_path.append(ImportFinder(self.watcher, finder))
581 sys.meta_path = meta_path
582
583 sitefix.monkeypatch_quit()
584 return self
585
586 def __exit__(
587 self,

Callers 1

sigtstp_handlerMethod · 0.95

Calls 2

ImportFinderClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected