MCPcopy Index your code
hub / github.com/ipython/ipython / default

Method default

IPython/core/debugger_backport.py:156–206  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

154 return True
155
156 def default(self, line): # type: ignore[no-untyped-def]
157 if line[:1] == "!":
158 line = line[1:].strip()
159 locals = self.curframe_locals
160 globals = self.curframe.f_globals
161 try:
162 buffer = line
163 if (
164 code := codeop.compile_command(line + "\n", "<stdin>", "single")
165 ) is None:
166 # Multi-line mode
167 with self._disable_command_completion():
168 buffer = line
169 continue_prompt = "... "
170 while (
171 code := codeop.compile_command(buffer, "<stdin>", "single")
172 ) is None:
173 if self.use_rawinput:
174 try:
175 line = input(continue_prompt)
176 except (EOFError, KeyboardInterrupt):
177 self.lastcmd = ""
178 print("\n")
179 return
180 else:
181 self.stdout.write(continue_prompt)
182 self.stdout.flush()
183 line = self.stdin.readline()
184 if not len(line):
185 self.lastcmd = ""
186 self.stdout.write("\n")
187 self.stdout.flush()
188 return
189 else:
190 line = line.rstrip("\r\n")
191 buffer += "\n" + line
192 save_stdout = sys.stdout
193 save_stdin = sys.stdin
194 save_displayhook = sys.displayhook
195 try:
196 sys.stdin = self.stdin
197 sys.stdout = self.stdout
198 sys.displayhook = self.displayhook
199 if not self._exec_in_closure(buffer, globals, locals):
200 exec(code, globals, locals)
201 finally:
202 sys.stdout = save_stdout
203 sys.stdin = save_stdin
204 sys.displayhook = save_displayhook
205 except:
206 self._error_exc()

Callers 2

runMethod · 0.80
gui-gtk4.pyFile · 0.80

Calls 5

_exec_in_closureMethod · 0.95
inputFunction · 0.85
readlineMethod · 0.80
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected