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

Method _enable_multiline_input

Lib/pdb.py:784–813  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

782
783 @contextmanager
784 def _enable_multiline_input(self):
785 try:
786 import readline
787 except ImportError:
788 yield
789 return
790
791 def input_auto_indent():
792 last_index = readline.get_current_history_length()
793 last_line = readline.get_history_item(last_index)
794 if last_line:
795 if last_line.isspace():
796 # If the last line is empty, we don't need to indent
797 return
798
799 last_line = last_line.rstrip('\r\n')
800 indent = len(last_line) - len(last_line.lstrip())
801 if last_line.endswith(":"):
802 indent += 4
803 readline.insert_text(' ' * indent)
804
805 completenames = self.completenames
806 try:
807 self.completenames = self.complete_multiline_names
808 readline.set_startup_hook(input_auto_indent)
809 yield
810 finally:
811 readline.set_startup_hook()
812 self.completenames = completenames
813 return
814
815 def _exec_in_closure(self, source, globals, locals):
816 """ Run source code in closure so code object created within source

Callers 1

_read_codeMethod · 0.95

Calls 1

set_startup_hookMethod · 0.80

Tested by

no test coverage detected