1 | n/a | import io |
---|
2 | n/a | import linecache |
---|
3 | n/a | import queue |
---|
4 | n/a | import sys |
---|
5 | n/a | import time |
---|
6 | n/a | import traceback |
---|
7 | n/a | import _thread as thread |
---|
8 | n/a | import threading |
---|
9 | n/a | import warnings |
---|
10 | n/a | |
---|
11 | n/a | import tkinter # Tcl, deletions, messagebox if startup fails |
---|
12 | n/a | |
---|
13 | n/a | from idlelib import autocomplete # AutoComplete, fetch_encodings |
---|
14 | n/a | from idlelib import calltips # CallTips |
---|
15 | n/a | from idlelib import debugger_r # start_debugger |
---|
16 | n/a | from idlelib import debugobj_r # remote_object_tree_item |
---|
17 | n/a | from idlelib import iomenu # encoding |
---|
18 | n/a | from idlelib import rpc # multiple objects |
---|
19 | n/a | from idlelib import stackviewer # StackTreeItem |
---|
20 | n/a | import __main__ |
---|
21 | n/a | |
---|
22 | n/a | for mod in ('simpledialog', 'messagebox', 'font', |
---|
23 | n/a | 'dialog', 'filedialog', 'commondialog', |
---|
24 | n/a | 'ttk'): |
---|
25 | n/a | delattr(tkinter, mod) |
---|
26 | n/a | del sys.modules['tkinter.' + mod] |
---|
27 | n/a | |
---|
28 | n/a | LOCALHOST = '127.0.0.1' |
---|
29 | n/a | |
---|
30 | n/a | |
---|
31 | n/a | def idle_formatwarning(message, category, filename, lineno, line=None): |
---|
32 | n/a | """Format warnings the IDLE way.""" |
---|
33 | n/a | |
---|
34 | n/a | s = "\nWarning (from warnings module):\n" |
---|
35 | n/a | s += ' File \"%s\", line %s\n' % (filename, lineno) |
---|
36 | n/a | if line is None: |
---|
37 | n/a | line = linecache.getline(filename, lineno) |
---|
38 | n/a | line = line.strip() |
---|
39 | n/a | if line: |
---|
40 | n/a | s += " %s\n" % line |
---|
41 | n/a | s += "%s: %s\n" % (category.__name__, message) |
---|
42 | n/a | return s |
---|
43 | n/a | |
---|
44 | n/a | def idle_showwarning_subproc( |
---|
45 | n/a | message, category, filename, lineno, file=None, line=None): |
---|
46 | n/a | """Show Idle-format warning after replacing warnings.showwarning. |
---|
47 | n/a | |
---|
48 | n/a | The only difference is the formatter called. |
---|
49 | n/a | """ |
---|
50 | n/a | if file is None: |
---|
51 | n/a | file = sys.stderr |
---|
52 | n/a | try: |
---|
53 | n/a | file.write(idle_formatwarning( |
---|
54 | n/a | message, category, filename, lineno, line)) |
---|
55 | n/a | except IOError: |
---|
56 | n/a | pass # the file (probably stderr) is invalid - this warning gets lost. |
---|
57 | n/a | |
---|
58 | n/a | _warnings_showwarning = None |
---|
59 | n/a | |
---|
60 | n/a | def capture_warnings(capture): |
---|
61 | n/a | "Replace warning.showwarning with idle_showwarning_subproc, or reverse." |
---|
62 | n/a | |
---|
63 | n/a | global _warnings_showwarning |
---|
64 | n/a | if capture: |
---|
65 | n/a | if _warnings_showwarning is None: |
---|
66 | n/a | _warnings_showwarning = warnings.showwarning |
---|
67 | n/a | warnings.showwarning = idle_showwarning_subproc |
---|
68 | n/a | else: |
---|
69 | n/a | if _warnings_showwarning is not None: |
---|
70 | n/a | warnings.showwarning = _warnings_showwarning |
---|
71 | n/a | _warnings_showwarning = None |
---|
72 | n/a | |
---|
73 | n/a | capture_warnings(True) |
---|
74 | n/a | tcl = tkinter.Tcl() |
---|
75 | n/a | |
---|
76 | n/a | def handle_tk_events(tcl=tcl): |
---|
77 | n/a | """Process any tk events that are ready to be dispatched if tkinter |
---|
78 | n/a | has been imported, a tcl interpreter has been created and tk has been |
---|
79 | n/a | loaded.""" |
---|
80 | n/a | tcl.eval("update") |
---|
81 | n/a | |
---|
82 | n/a | # Thread shared globals: Establish a queue between a subthread (which handles |
---|
83 | n/a | # the socket) and the main thread (which runs user code), plus global |
---|
84 | n/a | # completion, exit and interruptable (the main thread) flags: |
---|
85 | n/a | |
---|
86 | n/a | exit_now = False |
---|
87 | n/a | quitting = False |
---|
88 | n/a | interruptable = False |
---|
89 | n/a | |
---|
90 | n/a | def main(del_exitfunc=False): |
---|
91 | n/a | """Start the Python execution server in a subprocess |
---|
92 | n/a | |
---|
93 | n/a | In the Python subprocess, RPCServer is instantiated with handlerclass |
---|
94 | n/a | MyHandler, which inherits register/unregister methods from RPCHandler via |
---|
95 | n/a | the mix-in class SocketIO. |
---|
96 | n/a | |
---|
97 | n/a | When the RPCServer 'server' is instantiated, the TCPServer initialization |
---|
98 | n/a | creates an instance of run.MyHandler and calls its handle() method. |
---|
99 | n/a | handle() instantiates a run.Executive object, passing it a reference to the |
---|
100 | n/a | MyHandler object. That reference is saved as attribute rpchandler of the |
---|
101 | n/a | Executive instance. The Executive methods have access to the reference and |
---|
102 | n/a | can pass it on to entities that they command |
---|
103 | n/a | (e.g. debugger_r.Debugger.start_debugger()). The latter, in turn, can |
---|
104 | n/a | call MyHandler(SocketIO) register/unregister methods via the reference to |
---|
105 | n/a | register and unregister themselves. |
---|
106 | n/a | |
---|
107 | n/a | """ |
---|
108 | n/a | global exit_now |
---|
109 | n/a | global quitting |
---|
110 | n/a | global no_exitfunc |
---|
111 | n/a | no_exitfunc = del_exitfunc |
---|
112 | n/a | #time.sleep(15) # test subprocess not responding |
---|
113 | n/a | try: |
---|
114 | n/a | assert(len(sys.argv) > 1) |
---|
115 | n/a | port = int(sys.argv[-1]) |
---|
116 | n/a | except: |
---|
117 | n/a | print("IDLE Subprocess: no IP port passed in sys.argv.", |
---|
118 | n/a | file=sys.__stderr__) |
---|
119 | n/a | return |
---|
120 | n/a | |
---|
121 | n/a | capture_warnings(True) |
---|
122 | n/a | sys.argv[:] = [""] |
---|
123 | n/a | sockthread = threading.Thread(target=manage_socket, |
---|
124 | n/a | name='SockThread', |
---|
125 | n/a | args=((LOCALHOST, port),)) |
---|
126 | n/a | sockthread.daemon = True |
---|
127 | n/a | sockthread.start() |
---|
128 | n/a | while 1: |
---|
129 | n/a | try: |
---|
130 | n/a | if exit_now: |
---|
131 | n/a | try: |
---|
132 | n/a | exit() |
---|
133 | n/a | except KeyboardInterrupt: |
---|
134 | n/a | # exiting but got an extra KBI? Try again! |
---|
135 | n/a | continue |
---|
136 | n/a | try: |
---|
137 | n/a | seq, request = rpc.request_queue.get(block=True, timeout=0.05) |
---|
138 | n/a | except queue.Empty: |
---|
139 | n/a | handle_tk_events() |
---|
140 | n/a | continue |
---|
141 | n/a | method, args, kwargs = request |
---|
142 | n/a | ret = method(*args, **kwargs) |
---|
143 | n/a | rpc.response_queue.put((seq, ret)) |
---|
144 | n/a | except KeyboardInterrupt: |
---|
145 | n/a | if quitting: |
---|
146 | n/a | exit_now = True |
---|
147 | n/a | continue |
---|
148 | n/a | except SystemExit: |
---|
149 | n/a | capture_warnings(False) |
---|
150 | n/a | raise |
---|
151 | n/a | except: |
---|
152 | n/a | type, value, tb = sys.exc_info() |
---|
153 | n/a | try: |
---|
154 | n/a | print_exception() |
---|
155 | n/a | rpc.response_queue.put((seq, None)) |
---|
156 | n/a | except: |
---|
157 | n/a | # Link didn't work, print same exception to __stderr__ |
---|
158 | n/a | traceback.print_exception(type, value, tb, file=sys.__stderr__) |
---|
159 | n/a | exit() |
---|
160 | n/a | else: |
---|
161 | n/a | continue |
---|
162 | n/a | |
---|
163 | n/a | def manage_socket(address): |
---|
164 | n/a | for i in range(3): |
---|
165 | n/a | time.sleep(i) |
---|
166 | n/a | try: |
---|
167 | n/a | server = MyRPCServer(address, MyHandler) |
---|
168 | n/a | break |
---|
169 | n/a | except OSError as err: |
---|
170 | n/a | print("IDLE Subprocess: OSError: " + err.args[1] + |
---|
171 | n/a | ", retrying....", file=sys.__stderr__) |
---|
172 | n/a | socket_error = err |
---|
173 | n/a | else: |
---|
174 | n/a | print("IDLE Subprocess: Connection to " |
---|
175 | n/a | "IDLE GUI failed, exiting.", file=sys.__stderr__) |
---|
176 | n/a | show_socket_error(socket_error, address) |
---|
177 | n/a | global exit_now |
---|
178 | n/a | exit_now = True |
---|
179 | n/a | return |
---|
180 | n/a | server.handle_request() # A single request only |
---|
181 | n/a | |
---|
182 | n/a | def show_socket_error(err, address): |
---|
183 | n/a | import tkinter |
---|
184 | n/a | import tkinter.messagebox as tkMessageBox |
---|
185 | n/a | root = tkinter.Tk() |
---|
186 | n/a | root.withdraw() |
---|
187 | n/a | if err.args[0] == 61: # connection refused |
---|
188 | n/a | msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\ |
---|
189 | n/a | "to your personal firewall configuration. It is safe to "\ |
---|
190 | n/a | "allow this internal connection because no data is visible on "\ |
---|
191 | n/a | "external ports." % address |
---|
192 | n/a | tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root) |
---|
193 | n/a | else: |
---|
194 | n/a | tkMessageBox.showerror("IDLE Subprocess Error", |
---|
195 | n/a | "Socket Error: %s" % err.args[1], parent=root) |
---|
196 | n/a | root.destroy() |
---|
197 | n/a | |
---|
198 | n/a | def print_exception(): |
---|
199 | n/a | import linecache |
---|
200 | n/a | linecache.checkcache() |
---|
201 | n/a | flush_stdout() |
---|
202 | n/a | efile = sys.stderr |
---|
203 | n/a | typ, val, tb = excinfo = sys.exc_info() |
---|
204 | n/a | sys.last_type, sys.last_value, sys.last_traceback = excinfo |
---|
205 | n/a | seen = set() |
---|
206 | n/a | |
---|
207 | n/a | def print_exc(typ, exc, tb): |
---|
208 | n/a | seen.add(exc) |
---|
209 | n/a | context = exc.__context__ |
---|
210 | n/a | cause = exc.__cause__ |
---|
211 | n/a | if cause is not None and cause not in seen: |
---|
212 | n/a | print_exc(type(cause), cause, cause.__traceback__) |
---|
213 | n/a | print("\nThe above exception was the direct cause " |
---|
214 | n/a | "of the following exception:\n", file=efile) |
---|
215 | n/a | elif (context is not None and |
---|
216 | n/a | not exc.__suppress_context__ and |
---|
217 | n/a | context not in seen): |
---|
218 | n/a | print_exc(type(context), context, context.__traceback__) |
---|
219 | n/a | print("\nDuring handling of the above exception, " |
---|
220 | n/a | "another exception occurred:\n", file=efile) |
---|
221 | n/a | if tb: |
---|
222 | n/a | tbe = traceback.extract_tb(tb) |
---|
223 | n/a | print('Traceback (most recent call last):', file=efile) |
---|
224 | n/a | exclude = ("run.py", "rpc.py", "threading.py", "queue.py", |
---|
225 | n/a | "debugger_r.py", "bdb.py") |
---|
226 | n/a | cleanup_traceback(tbe, exclude) |
---|
227 | n/a | traceback.print_list(tbe, file=efile) |
---|
228 | n/a | lines = traceback.format_exception_only(typ, exc) |
---|
229 | n/a | for line in lines: |
---|
230 | n/a | print(line, end='', file=efile) |
---|
231 | n/a | |
---|
232 | n/a | print_exc(typ, val, tb) |
---|
233 | n/a | |
---|
234 | n/a | def cleanup_traceback(tb, exclude): |
---|
235 | n/a | "Remove excluded traces from beginning/end of tb; get cached lines" |
---|
236 | n/a | orig_tb = tb[:] |
---|
237 | n/a | while tb: |
---|
238 | n/a | for rpcfile in exclude: |
---|
239 | n/a | if tb[0][0].count(rpcfile): |
---|
240 | n/a | break # found an exclude, break for: and delete tb[0] |
---|
241 | n/a | else: |
---|
242 | n/a | break # no excludes, have left RPC code, break while: |
---|
243 | n/a | del tb[0] |
---|
244 | n/a | while tb: |
---|
245 | n/a | for rpcfile in exclude: |
---|
246 | n/a | if tb[-1][0].count(rpcfile): |
---|
247 | n/a | break |
---|
248 | n/a | else: |
---|
249 | n/a | break |
---|
250 | n/a | del tb[-1] |
---|
251 | n/a | if len(tb) == 0: |
---|
252 | n/a | # exception was in IDLE internals, don't prune! |
---|
253 | n/a | tb[:] = orig_tb[:] |
---|
254 | n/a | print("** IDLE Internal Exception: ", file=sys.stderr) |
---|
255 | n/a | rpchandler = rpc.objecttable['exec'].rpchandler |
---|
256 | n/a | for i in range(len(tb)): |
---|
257 | n/a | fn, ln, nm, line = tb[i] |
---|
258 | n/a | if nm == '?': |
---|
259 | n/a | nm = "-toplevel-" |
---|
260 | n/a | if not line and fn.startswith("<pyshell#"): |
---|
261 | n/a | line = rpchandler.remotecall('linecache', 'getline', |
---|
262 | n/a | (fn, ln), {}) |
---|
263 | n/a | tb[i] = fn, ln, nm, line |
---|
264 | n/a | |
---|
265 | n/a | def flush_stdout(): |
---|
266 | n/a | """XXX How to do this now?""" |
---|
267 | n/a | |
---|
268 | n/a | def exit(): |
---|
269 | n/a | """Exit subprocess, possibly after first clearing exit functions. |
---|
270 | n/a | |
---|
271 | n/a | If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any |
---|
272 | n/a | functions registered with atexit will be removed before exiting. |
---|
273 | n/a | (VPython support) |
---|
274 | n/a | |
---|
275 | n/a | """ |
---|
276 | n/a | if no_exitfunc: |
---|
277 | n/a | import atexit |
---|
278 | n/a | atexit._clear() |
---|
279 | n/a | capture_warnings(False) |
---|
280 | n/a | sys.exit(0) |
---|
281 | n/a | |
---|
282 | n/a | |
---|
283 | n/a | class MyRPCServer(rpc.RPCServer): |
---|
284 | n/a | |
---|
285 | n/a | def handle_error(self, request, client_address): |
---|
286 | n/a | """Override RPCServer method for IDLE |
---|
287 | n/a | |
---|
288 | n/a | Interrupt the MainThread and exit server if link is dropped. |
---|
289 | n/a | |
---|
290 | n/a | """ |
---|
291 | n/a | global quitting |
---|
292 | n/a | try: |
---|
293 | n/a | raise |
---|
294 | n/a | except SystemExit: |
---|
295 | n/a | raise |
---|
296 | n/a | except EOFError: |
---|
297 | n/a | global exit_now |
---|
298 | n/a | exit_now = True |
---|
299 | n/a | thread.interrupt_main() |
---|
300 | n/a | except: |
---|
301 | n/a | erf = sys.__stderr__ |
---|
302 | n/a | print('\n' + '-'*40, file=erf) |
---|
303 | n/a | print('Unhandled server exception!', file=erf) |
---|
304 | n/a | print('Thread: %s' % threading.current_thread().name, file=erf) |
---|
305 | n/a | print('Client Address: ', client_address, file=erf) |
---|
306 | n/a | print('Request: ', repr(request), file=erf) |
---|
307 | n/a | traceback.print_exc(file=erf) |
---|
308 | n/a | print('\n*** Unrecoverable, server exiting!', file=erf) |
---|
309 | n/a | print('-'*40, file=erf) |
---|
310 | n/a | quitting = True |
---|
311 | n/a | thread.interrupt_main() |
---|
312 | n/a | |
---|
313 | n/a | |
---|
314 | n/a | # Pseudofiles for shell-remote communication (also used in pyshell) |
---|
315 | n/a | |
---|
316 | n/a | class PseudoFile(io.TextIOBase): |
---|
317 | n/a | |
---|
318 | n/a | def __init__(self, shell, tags, encoding=None): |
---|
319 | n/a | self.shell = shell |
---|
320 | n/a | self.tags = tags |
---|
321 | n/a | self._encoding = encoding |
---|
322 | n/a | |
---|
323 | n/a | @property |
---|
324 | n/a | def encoding(self): |
---|
325 | n/a | return self._encoding |
---|
326 | n/a | |
---|
327 | n/a | @property |
---|
328 | n/a | def name(self): |
---|
329 | n/a | return '<%s>' % self.tags |
---|
330 | n/a | |
---|
331 | n/a | def isatty(self): |
---|
332 | n/a | return True |
---|
333 | n/a | |
---|
334 | n/a | |
---|
335 | n/a | class PseudoOutputFile(PseudoFile): |
---|
336 | n/a | |
---|
337 | n/a | def writable(self): |
---|
338 | n/a | return True |
---|
339 | n/a | |
---|
340 | n/a | def write(self, s): |
---|
341 | n/a | if self.closed: |
---|
342 | n/a | raise ValueError("write to closed file") |
---|
343 | n/a | if type(s) is not str: |
---|
344 | n/a | if not isinstance(s, str): |
---|
345 | n/a | raise TypeError('must be str, not ' + type(s).__name__) |
---|
346 | n/a | # See issue #19481 |
---|
347 | n/a | s = str.__str__(s) |
---|
348 | n/a | return self.shell.write(s, self.tags) |
---|
349 | n/a | |
---|
350 | n/a | |
---|
351 | n/a | class PseudoInputFile(PseudoFile): |
---|
352 | n/a | |
---|
353 | n/a | def __init__(self, shell, tags, encoding=None): |
---|
354 | n/a | PseudoFile.__init__(self, shell, tags, encoding) |
---|
355 | n/a | self._line_buffer = '' |
---|
356 | n/a | |
---|
357 | n/a | def readable(self): |
---|
358 | n/a | return True |
---|
359 | n/a | |
---|
360 | n/a | def read(self, size=-1): |
---|
361 | n/a | if self.closed: |
---|
362 | n/a | raise ValueError("read from closed file") |
---|
363 | n/a | if size is None: |
---|
364 | n/a | size = -1 |
---|
365 | n/a | elif not isinstance(size, int): |
---|
366 | n/a | raise TypeError('must be int, not ' + type(size).__name__) |
---|
367 | n/a | result = self._line_buffer |
---|
368 | n/a | self._line_buffer = '' |
---|
369 | n/a | if size < 0: |
---|
370 | n/a | while True: |
---|
371 | n/a | line = self.shell.readline() |
---|
372 | n/a | if not line: break |
---|
373 | n/a | result += line |
---|
374 | n/a | else: |
---|
375 | n/a | while len(result) < size: |
---|
376 | n/a | line = self.shell.readline() |
---|
377 | n/a | if not line: break |
---|
378 | n/a | result += line |
---|
379 | n/a | self._line_buffer = result[size:] |
---|
380 | n/a | result = result[:size] |
---|
381 | n/a | return result |
---|
382 | n/a | |
---|
383 | n/a | def readline(self, size=-1): |
---|
384 | n/a | if self.closed: |
---|
385 | n/a | raise ValueError("read from closed file") |
---|
386 | n/a | if size is None: |
---|
387 | n/a | size = -1 |
---|
388 | n/a | elif not isinstance(size, int): |
---|
389 | n/a | raise TypeError('must be int, not ' + type(size).__name__) |
---|
390 | n/a | line = self._line_buffer or self.shell.readline() |
---|
391 | n/a | if size < 0: |
---|
392 | n/a | size = len(line) |
---|
393 | n/a | eol = line.find('\n', 0, size) |
---|
394 | n/a | if eol >= 0: |
---|
395 | n/a | size = eol + 1 |
---|
396 | n/a | self._line_buffer = line[size:] |
---|
397 | n/a | return line[:size] |
---|
398 | n/a | |
---|
399 | n/a | def close(self): |
---|
400 | n/a | self.shell.close() |
---|
401 | n/a | |
---|
402 | n/a | |
---|
403 | n/a | class MyHandler(rpc.RPCHandler): |
---|
404 | n/a | |
---|
405 | n/a | def handle(self): |
---|
406 | n/a | """Override base method""" |
---|
407 | n/a | executive = Executive(self) |
---|
408 | n/a | self.register("exec", executive) |
---|
409 | n/a | self.console = self.get_remote_proxy("console") |
---|
410 | n/a | sys.stdin = PseudoInputFile(self.console, "stdin", |
---|
411 | n/a | iomenu.encoding) |
---|
412 | n/a | sys.stdout = PseudoOutputFile(self.console, "stdout", |
---|
413 | n/a | iomenu.encoding) |
---|
414 | n/a | sys.stderr = PseudoOutputFile(self.console, "stderr", |
---|
415 | n/a | iomenu.encoding) |
---|
416 | n/a | |
---|
417 | n/a | sys.displayhook = rpc.displayhook |
---|
418 | n/a | # page help() text to shell. |
---|
419 | n/a | import pydoc # import must be done here to capture i/o binding |
---|
420 | n/a | pydoc.pager = pydoc.plainpager |
---|
421 | n/a | |
---|
422 | n/a | # Keep a reference to stdin so that it won't try to exit IDLE if |
---|
423 | n/a | # sys.stdin gets changed from within IDLE's shell. See issue17838. |
---|
424 | n/a | self._keep_stdin = sys.stdin |
---|
425 | n/a | |
---|
426 | n/a | self.interp = self.get_remote_proxy("interp") |
---|
427 | n/a | rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) |
---|
428 | n/a | |
---|
429 | n/a | def exithook(self): |
---|
430 | n/a | "override SocketIO method - wait for MainThread to shut us down" |
---|
431 | n/a | time.sleep(10) |
---|
432 | n/a | |
---|
433 | n/a | def EOFhook(self): |
---|
434 | n/a | "Override SocketIO method - terminate wait on callback and exit thread" |
---|
435 | n/a | global quitting |
---|
436 | n/a | quitting = True |
---|
437 | n/a | thread.interrupt_main() |
---|
438 | n/a | |
---|
439 | n/a | def decode_interrupthook(self): |
---|
440 | n/a | "interrupt awakened thread" |
---|
441 | n/a | global quitting |
---|
442 | n/a | quitting = True |
---|
443 | n/a | thread.interrupt_main() |
---|
444 | n/a | |
---|
445 | n/a | |
---|
446 | n/a | class Executive(object): |
---|
447 | n/a | |
---|
448 | n/a | def __init__(self, rpchandler): |
---|
449 | n/a | self.rpchandler = rpchandler |
---|
450 | n/a | self.locals = __main__.__dict__ |
---|
451 | n/a | self.calltip = calltips.CallTips() |
---|
452 | n/a | self.autocomplete = autocomplete.AutoComplete() |
---|
453 | n/a | |
---|
454 | n/a | def runcode(self, code): |
---|
455 | n/a | global interruptable |
---|
456 | n/a | try: |
---|
457 | n/a | self.usr_exc_info = None |
---|
458 | n/a | interruptable = True |
---|
459 | n/a | try: |
---|
460 | n/a | exec(code, self.locals) |
---|
461 | n/a | finally: |
---|
462 | n/a | interruptable = False |
---|
463 | n/a | except SystemExit: |
---|
464 | n/a | # Scripts that raise SystemExit should just |
---|
465 | n/a | # return to the interactive prompt |
---|
466 | n/a | pass |
---|
467 | n/a | except: |
---|
468 | n/a | self.usr_exc_info = sys.exc_info() |
---|
469 | n/a | if quitting: |
---|
470 | n/a | exit() |
---|
471 | n/a | # even print a user code SystemExit exception, continue |
---|
472 | n/a | print_exception() |
---|
473 | n/a | jit = self.rpchandler.console.getvar("<<toggle-jit-stack-viewer>>") |
---|
474 | n/a | if jit: |
---|
475 | n/a | self.rpchandler.interp.open_remote_stack_viewer() |
---|
476 | n/a | else: |
---|
477 | n/a | flush_stdout() |
---|
478 | n/a | |
---|
479 | n/a | def interrupt_the_server(self): |
---|
480 | n/a | if interruptable: |
---|
481 | n/a | thread.interrupt_main() |
---|
482 | n/a | |
---|
483 | n/a | def start_the_debugger(self, gui_adap_oid): |
---|
484 | n/a | return debugger_r.start_debugger(self.rpchandler, gui_adap_oid) |
---|
485 | n/a | |
---|
486 | n/a | def stop_the_debugger(self, idb_adap_oid): |
---|
487 | n/a | "Unregister the Idb Adapter. Link objects and Idb then subject to GC" |
---|
488 | n/a | self.rpchandler.unregister(idb_adap_oid) |
---|
489 | n/a | |
---|
490 | n/a | def get_the_calltip(self, name): |
---|
491 | n/a | return self.calltip.fetch_tip(name) |
---|
492 | n/a | |
---|
493 | n/a | def get_the_completion_list(self, what, mode): |
---|
494 | n/a | return self.autocomplete.fetch_completions(what, mode) |
---|
495 | n/a | |
---|
496 | n/a | def stackviewer(self, flist_oid=None): |
---|
497 | n/a | if self.usr_exc_info: |
---|
498 | n/a | typ, val, tb = self.usr_exc_info |
---|
499 | n/a | else: |
---|
500 | n/a | return None |
---|
501 | n/a | flist = None |
---|
502 | n/a | if flist_oid is not None: |
---|
503 | n/a | flist = self.rpchandler.get_remote_proxy(flist_oid) |
---|
504 | n/a | while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]: |
---|
505 | n/a | tb = tb.tb_next |
---|
506 | n/a | sys.last_type = typ |
---|
507 | n/a | sys.last_value = val |
---|
508 | n/a | item = stackviewer.StackTreeItem(flist, tb) |
---|
509 | n/a | return debugobj_r.remote_object_tree_item(item) |
---|
510 | n/a | |
---|
511 | n/a | capture_warnings(False) # Make sure turned off; see issue 18081 |
---|