blob: 28ce4200a92a534919ea5881fc1c8b5f510d81b1 [file] [log] [blame]
Chui Tey5d2af632002-05-26 13:36:41 +00001import sys
Kurt B. Kaiser49a5fe12004-07-04 01:25:56 +00002import linecache
Kurt B. Kaiserb4179362002-07-26 00:06:42 +00003import time
Kurt B. Kaiser86bc4642003-02-27 23:04:17 +00004import traceback
Georg Brandl2067bfd2008-05-25 13:05:15 +00005import _thread as thread
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +00006import threading
Alexandre Vassalottif260e442008-05-11 19:59:59 +00007import queue
Andrew Svetlov753445a2012-03-26 21:56:44 +03008import tkinter
Kurt B. Kaiser5afa1df2002-10-10 08:25:24 +00009
Kurt B. Kaiser2d7f6a02007-08-22 23:01:33 +000010from idlelib import CallTips
11from idlelib import AutoComplete
Kurt B. Kaiserb1754452005-11-18 22:05:48 +000012
Kurt B. Kaiser2d7f6a02007-08-22 23:01:33 +000013from idlelib import RemoteDebugger
14from idlelib import RemoteObjectBrowser
15from idlelib import StackViewer
16from idlelib import rpc
Serhiy Storchaka39e70a42013-01-25 15:30:58 +020017from idlelib import PyShell
18from idlelib import IOBinding
Chui Tey5d2af632002-05-26 13:36:41 +000019
Kurt B. Kaiser5afa1df2002-10-10 08:25:24 +000020import __main__
21
Terry Jan Reedyff1d5ab2016-07-16 18:26:32 -040022for mod in ('simpledialog', 'messagebox', 'font',
23 'dialog', 'filedialog', 'commondialog',
24 'colorchooser'):
25 delattr(tkinter, mod)
26 del sys.modules['tkinter.' + mod]
27
Kurt B. Kaiser24d7e0c2003-06-05 23:51:29 +000028LOCALHOST = '127.0.0.1'
29
Terry Jan Reedy95a3f112013-06-28 23:50:12 -040030import warnings
Kurt B. Kaiser49a5fe12004-07-04 01:25:56 +000031
Terry Jan Reedy95a3f112013-06-28 23:50:12 -040032def idle_showwarning_subproc(
33 message, category, filename, lineno, file=None, line=None):
34 """Show Idle-format warning after replacing warnings.showwarning.
Andrew Svetlova2251aa2012-03-13 18:36:13 -070035
Terry Jan Reedy95a3f112013-06-28 23:50:12 -040036 The only difference is the formatter called.
37 """
38 if file is None:
39 file = sys.stderr
40 try:
41 file.write(PyShell.idle_formatwarning(
42 message, category, filename, lineno, line))
43 except IOError:
44 pass # the file (probably stderr) is invalid - this warning gets lost.
45
46_warnings_showwarning = None
47
48def capture_warnings(capture):
49 "Replace warning.showwarning with idle_showwarning_subproc, or reverse."
50
51 global _warnings_showwarning
52 if capture:
53 if _warnings_showwarning is None:
54 _warnings_showwarning = warnings.showwarning
55 warnings.showwarning = idle_showwarning_subproc
56 else:
57 if _warnings_showwarning is not None:
58 warnings.showwarning = _warnings_showwarning
59 _warnings_showwarning = None
60
61capture_warnings(True)
Andrew Svetlov753445a2012-03-26 21:56:44 +030062tcl = tkinter.Tcl()
63
Andrew Svetlov753445a2012-03-26 21:56:44 +030064def handle_tk_events(tcl=tcl):
Andrew Svetlova2251aa2012-03-13 18:36:13 -070065 """Process any tk events that are ready to be dispatched if tkinter
66 has been imported, a tcl interpreter has been created and tk has been
67 loaded."""
Andrew Svetlov753445a2012-03-26 21:56:44 +030068 tcl.eval("update")
Andrew Svetlova2251aa2012-03-13 18:36:13 -070069
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +000070# Thread shared globals: Establish a queue between a subthread (which handles
71# the socket) and the main thread (which runs user code), plus global
Guido van Rossum8ce8a782007-11-01 19:42:39 +000072# completion, exit and interruptable (the main thread) flags:
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +000073
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +000074exit_now = False
75quitting = False
Guido van Rossum8ce8a782007-11-01 19:42:39 +000076interruptable = False
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +000077
Kurt B. Kaiser62df0442003-05-28 01:47:46 +000078def main(del_exitfunc=False):
Kurt B. Kaiserb4179362002-07-26 00:06:42 +000079 """Start the Python execution server in a subprocess
80
Kurt B. Kaiser5afa1df2002-10-10 08:25:24 +000081 In the Python subprocess, RPCServer is instantiated with handlerclass
82 MyHandler, which inherits register/unregister methods from RPCHandler via
83 the mix-in class SocketIO.
Kurt B. Kaiserb4179362002-07-26 00:06:42 +000084
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +000085 When the RPCServer 'server' is instantiated, the TCPServer initialization
Kurt B. Kaiser5afa1df2002-10-10 08:25:24 +000086 creates an instance of run.MyHandler and calls its handle() method.
87 handle() instantiates a run.Executive object, passing it a reference to the
88 MyHandler object. That reference is saved as attribute rpchandler of the
89 Executive instance. The Executive methods have access to the reference and
90 can pass it on to entities that they command
91 (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can
92 call MyHandler(SocketIO) register/unregister methods via the reference to
93 register and unregister themselves.
Kurt B. Kaiserb4179362002-07-26 00:06:42 +000094
95 """
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +000096 global exit_now
97 global quitting
Kurt B. Kaiser62df0442003-05-28 01:47:46 +000098 global no_exitfunc
99 no_exitfunc = del_exitfunc
Kurt B. Kaiseraf3eb872004-01-21 18:54:30 +0000100 #time.sleep(15) # test subprocess not responding
Kurt B. Kaisere67842a2009-04-04 20:13:23 +0000101 try:
102 assert(len(sys.argv) > 1)
103 port = int(sys.argv[-1])
104 except:
Kurt B. Kaiser8fc98c32009-04-04 20:20:29 +0000105 print("IDLE Subprocess: no IP port passed in sys.argv.",
106 file=sys.__stderr__)
Kurt B. Kaisere67842a2009-04-04 20:13:23 +0000107 return
Terry Jan Reedy95a3f112013-06-28 23:50:12 -0400108
109 capture_warnings(True)
Chui Tey5d2af632002-05-26 13:36:41 +0000110 sys.argv[:] = [""]
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000111 sockthread = threading.Thread(target=manage_socket,
112 name='SockThread',
Kurt B. Kaiser24d7e0c2003-06-05 23:51:29 +0000113 args=((LOCALHOST, port),))
Benjamin Peterson71088cc2008-09-19 21:49:37 +0000114 sockthread.daemon = True
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000115 sockthread.start()
116 while 1:
117 try:
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000118 if exit_now:
119 try:
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000120 exit()
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000121 except KeyboardInterrupt:
122 # exiting but got an extra KBI? Try again!
123 continue
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000124 try:
Kurt B. Kaiser20345fb2005-05-05 23:29:54 +0000125 seq, request = rpc.request_queue.get(block=True, timeout=0.05)
Alexandre Vassalottif260e442008-05-11 19:59:59 +0000126 except queue.Empty:
Andrew Svetlova2251aa2012-03-13 18:36:13 -0700127 handle_tk_events()
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000128 continue
129 method, args, kwargs = request
130 ret = method(*args, **kwargs)
131 rpc.response_queue.put((seq, ret))
Kurt B. Kaiseraa6b8562003-05-14 18:15:40 +0000132 except KeyboardInterrupt:
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000133 if quitting:
134 exit_now = True
Kurt B. Kaiseraa6b8562003-05-14 18:15:40 +0000135 continue
Kurt B. Kaisera2792be2003-05-17 21:04:10 +0000136 except SystemExit:
Terry Jan Reedy95a3f112013-06-28 23:50:12 -0400137 capture_warnings(False)
Kurt B. Kaisera2792be2003-05-17 21:04:10 +0000138 raise
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000139 except:
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000140 type, value, tb = sys.exc_info()
Kurt B. Kaisera2792be2003-05-17 21:04:10 +0000141 try:
142 print_exception()
143 rpc.response_queue.put((seq, None))
144 except:
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000145 # Link didn't work, print same exception to __stderr__
146 traceback.print_exception(type, value, tb, file=sys.__stderr__)
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000147 exit()
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000148 else:
149 continue
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000150
151def manage_socket(address):
Kurt B. Kaiseraf3eb872004-01-21 18:54:30 +0000152 for i in range(3):
Kurt B. Kaiserb4179362002-07-26 00:06:42 +0000153 time.sleep(i)
154 try:
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000155 server = MyRPCServer(address, MyHandler)
Kurt B. Kaiserb4179362002-07-26 00:06:42 +0000156 break
Andrew Svetlov0832af62012-12-18 23:10:48 +0200157 except OSError as err:
158 print("IDLE Subprocess: OSError: " + err.args[1] +
Georg Brandl6464d472007-10-22 16:16:13 +0000159 ", retrying....", file=sys.__stderr__)
Amaury Forgeot d'Arcefae8c42008-11-21 23:08:09 +0000160 socket_error = err
Kurt B. Kaiserb4179362002-07-26 00:06:42 +0000161 else:
Amaury Forgeot d'Arcefae8c42008-11-21 23:08:09 +0000162 print("IDLE Subprocess: Connection to "
163 "IDLE GUI failed, exiting.", file=sys.__stderr__)
164 show_socket_error(socket_error, address)
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000165 global exit_now
166 exit_now = True
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000167 return
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000168 server.handle_request() # A single request only
169
Kurt B. Kaiseraf3eb872004-01-21 18:54:30 +0000170def show_socket_error(err, address):
Georg Brandl14fc4272008-05-17 18:39:55 +0000171 import tkinter
172 import tkinter.messagebox as tkMessageBox
173 root = tkinter.Tk()
Kurt B. Kaiseraf3eb872004-01-21 18:54:30 +0000174 root.withdraw()
Georg Brandl6464d472007-10-22 16:16:13 +0000175 if err.args[0] == 61: # connection refused
Kurt B. Kaiseraf3eb872004-01-21 18:54:30 +0000176 msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\
177 "to your personal firewall configuration. It is safe to "\
178 "allow this internal connection because no data is visible on "\
179 "external ports." % address
180 tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root)
181 else:
Georg Brandl6464d472007-10-22 16:16:13 +0000182 tkMessageBox.showerror("IDLE Subprocess Error",
Terry Jan Reedy3be2e542015-09-25 22:22:55 -0400183 "Socket Error: %s" % err.args[1], parent=root)
Kurt B. Kaiseraf3eb872004-01-21 18:54:30 +0000184 root.destroy()
185
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000186def print_exception():
Kurt B. Kaisere9802a32004-01-02 04:04:04 +0000187 import linecache
188 linecache.checkcache()
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000189 flush_stdout()
190 efile = sys.stderr
Kurt B. Kaiser924f6162003-11-19 04:52:32 +0000191 typ, val, tb = excinfo = sys.exc_info()
192 sys.last_type, sys.last_value, sys.last_traceback = excinfo
Serhiy Storchaka78470b42013-01-09 12:21:57 +0200193 seen = set()
194
195 def print_exc(typ, exc, tb):
196 seen.add(exc)
197 context = exc.__context__
198 cause = exc.__cause__
199 if cause is not None and cause not in seen:
200 print_exc(type(cause), cause, cause.__traceback__)
201 print("\nThe above exception was the direct cause "
202 "of the following exception:\n", file=efile)
Serhiy Storchaka71317492013-01-09 12:24:48 +0200203 elif (context is not None and
204 not exc.__suppress_context__ and
205 context not in seen):
Serhiy Storchaka78470b42013-01-09 12:21:57 +0200206 print_exc(type(context), context, context.__traceback__)
207 print("\nDuring handling of the above exception, "
208 "another exception occurred:\n", file=efile)
209 if tb:
210 tbe = traceback.extract_tb(tb)
211 print('Traceback (most recent call last):', file=efile)
212 exclude = ("run.py", "rpc.py", "threading.py", "queue.py",
213 "RemoteDebugger.py", "bdb.py")
214 cleanup_traceback(tbe, exclude)
215 traceback.print_list(tbe, file=efile)
216 lines = traceback.format_exception_only(typ, exc)
217 for line in lines:
218 print(line, end='', file=efile)
219
220 print_exc(typ, val, tb)
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000221
222def cleanup_traceback(tb, exclude):
223 "Remove excluded traces from beginning/end of tb; get cached lines"
224 orig_tb = tb[:]
225 while tb:
226 for rpcfile in exclude:
227 if tb[0][0].count(rpcfile):
228 break # found an exclude, break for: and delete tb[0]
229 else:
230 break # no excludes, have left RPC code, break while:
231 del tb[0]
232 while tb:
233 for rpcfile in exclude:
234 if tb[-1][0].count(rpcfile):
235 break
236 else:
237 break
238 del tb[-1]
239 if len(tb) == 0:
240 # exception was in IDLE internals, don't prune!
241 tb[:] = orig_tb[:]
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000242 print("** IDLE Internal Exception: ", file=sys.stderr)
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000243 rpchandler = rpc.objecttable['exec'].rpchandler
244 for i in range(len(tb)):
245 fn, ln, nm, line = tb[i]
246 if nm == '?':
247 nm = "-toplevel-"
248 if not line and fn.startswith("<pyshell#"):
249 line = rpchandler.remotecall('linecache', 'getline',
250 (fn, ln), {})
251 tb[i] = fn, ln, nm, line
252
253def flush_stdout():
Guido van Rossum79139b22007-02-09 23:20:19 +0000254 """XXX How to do this now?"""
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000255
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000256def exit():
Guido van Rossumc76a2502007-08-09 14:26:58 +0000257 """Exit subprocess, possibly after first clearing exit functions.
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000258
259 If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
Guido van Rossumc76a2502007-08-09 14:26:58 +0000260 functions registered with atexit will be removed before exiting.
261 (VPython support)
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000262
263 """
264 if no_exitfunc:
Guido van Rossumc76a2502007-08-09 14:26:58 +0000265 import atexit
266 atexit._clear()
Terry Jan Reedy95a3f112013-06-28 23:50:12 -0400267 capture_warnings(False)
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000268 sys.exit(0)
Chui Tey5d2af632002-05-26 13:36:41 +0000269
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000270class MyRPCServer(rpc.RPCServer):
271
272 def handle_error(self, request, client_address):
273 """Override RPCServer method for IDLE
274
275 Interrupt the MainThread and exit server if link is dropped.
276
277 """
Kurt B. Kaisere9535112004-11-19 15:46:49 +0000278 global quitting
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000279 try:
280 raise
281 except SystemExit:
282 raise
283 except EOFError:
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000284 global exit_now
285 exit_now = True
Kurt B. Kaiser93e8e542003-06-13 22:03:43 +0000286 thread.interrupt_main()
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000287 except:
288 erf = sys.__stderr__
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000289 print('\n' + '-'*40, file=erf)
290 print('Unhandled server exception!', file=erf)
Amaury Forgeot d'Arcbed17102008-11-29 01:48:47 +0000291 print('Thread: %s' % threading.current_thread().name, file=erf)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000292 print('Client Address: ', client_address, file=erf)
293 print('Request: ', repr(request), file=erf)
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000294 traceback.print_exc(file=erf)
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000295 print('\n*** Unrecoverable, server exiting!', file=erf)
296 print('-'*40, file=erf)
Kurt B. Kaisere9535112004-11-19 15:46:49 +0000297 quitting = True
298 thread.interrupt_main()
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000299
Chui Tey5d2af632002-05-26 13:36:41 +0000300class MyHandler(rpc.RPCHandler):
301
302 def handle(self):
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000303 """Override base method"""
Chui Tey5d2af632002-05-26 13:36:41 +0000304 executive = Executive(self)
305 self.register("exec", executive)
Serhiy Storchaka39e70a42013-01-25 15:30:58 +0200306 self.console = self.get_remote_proxy("console")
307 sys.stdin = PyShell.PseudoInputFile(self.console, "stdin",
308 IOBinding.encoding)
309 sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout",
310 IOBinding.encoding)
311 sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr",
312 IOBinding.encoding)
313
Andrew Svetlovcd49d532012-03-25 11:43:02 +0300314 sys.displayhook = rpc.displayhook
Kurt B. Kaiserf609a342007-12-28 03:57:56 +0000315 # page help() text to shell.
316 import pydoc # import must be done here to capture i/o binding
317 pydoc.pager = pydoc.plainpager
Benjamin Peterson0d4931e2013-05-11 22:24:28 -0500318
319 # Keep a reference to stdin so that it won't try to exit IDLE if
320 # sys.stdin gets changed from within IDLE's shell. See issue17838.
321 self._keep_stdin = sys.stdin
322
Kurt B. Kaiser9f366092003-06-02 01:50:19 +0000323 self.interp = self.get_remote_proxy("interp")
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000324 rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05)
325
326 def exithook(self):
327 "override SocketIO method - wait for MainThread to shut us down"
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000328 time.sleep(10)
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000329
330 def EOFhook(self):
331 "Override SocketIO method - terminate wait on callback and exit thread"
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000332 global quitting
333 quitting = True
Kurt B. Kaiser93e8e542003-06-13 22:03:43 +0000334 thread.interrupt_main()
Kurt B. Kaisera00050f2003-05-08 20:26:55 +0000335
336 def decode_interrupthook(self):
337 "interrupt awakened thread"
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000338 global quitting
339 quitting = True
Kurt B. Kaiser93e8e542003-06-13 22:03:43 +0000340 thread.interrupt_main()
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000341
Chui Tey5d2af632002-05-26 13:36:41 +0000342
Kurt B. Kaiserdcba6622004-12-21 22:10:32 +0000343class Executive(object):
Chui Tey5d2af632002-05-26 13:36:41 +0000344
345 def __init__(self, rpchandler):
Kurt B. Kaiserffd3a422002-06-26 02:32:09 +0000346 self.rpchandler = rpchandler
Kurt B. Kaiseradc63842002-08-25 14:08:07 +0000347 self.locals = __main__.__dict__
Kurt B. Kaiser5afa1df2002-10-10 08:25:24 +0000348 self.calltip = CallTips.CallTips()
Kurt B. Kaiserb1754452005-11-18 22:05:48 +0000349 self.autocomplete = AutoComplete.AutoComplete()
Chui Tey5d2af632002-05-26 13:36:41 +0000350
351 def runcode(self, code):
Guido van Rossum8ce8a782007-11-01 19:42:39 +0000352 global interruptable
Kurt B. Kaiser86bc4642003-02-27 23:04:17 +0000353 try:
Kurt B. Kaiser9f366092003-06-02 01:50:19 +0000354 self.usr_exc_info = None
Guido van Rossum8ce8a782007-11-01 19:42:39 +0000355 interruptable = True
356 try:
357 exec(code, self.locals)
358 finally:
359 interruptable = False
Roger Serwyf4675212013-06-11 22:25:14 -0500360 except SystemExit:
361 # Scripts that raise SystemExit should just
362 # return to the interactive prompt
363 pass
Kurt B. Kaiser86bc4642003-02-27 23:04:17 +0000364 except:
Kurt B. Kaiser9f366092003-06-02 01:50:19 +0000365 self.usr_exc_info = sys.exc_info()
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000366 if quitting:
Kurt B. Kaiser62df0442003-05-28 01:47:46 +0000367 exit()
Kurt B. Kaiser67fd0ea2003-05-24 20:59:15 +0000368 # even print a user code SystemExit exception, continue
369 print_exception()
Kurt B. Kaiser9f366092003-06-02 01:50:19 +0000370 jit = self.rpchandler.console.getvar("<<toggle-jit-stack-viewer>>")
371 if jit:
372 self.rpchandler.interp.open_remote_stack_viewer()
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000373 else:
Kurt B. Kaiser9ec454e2003-05-12 02:33:47 +0000374 flush_stdout()
Chui Tey5d2af632002-05-26 13:36:41 +0000375
Kurt B. Kaiser003091c2003-02-17 18:57:16 +0000376 def interrupt_the_server(self):
Guido van Rossum8ce8a782007-11-01 19:42:39 +0000377 if interruptable:
378 thread.interrupt_main()
Kurt B. Kaiser11c53e22003-03-22 19:40:19 +0000379
Kurt B. Kaiser0e3a5772002-06-16 03:32:24 +0000380 def start_the_debugger(self, gui_adap_oid):
Kurt B. Kaiserffd3a422002-06-26 02:32:09 +0000381 return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid)
382
383 def stop_the_debugger(self, idb_adap_oid):
384 "Unregister the Idb Adapter. Link objects and Idb then subject to GC"
385 self.rpchandler.unregister(idb_adap_oid)
Chui Tey5d2af632002-05-26 13:36:41 +0000386
Kurt B. Kaiser5afa1df2002-10-10 08:25:24 +0000387 def get_the_calltip(self, name):
388 return self.calltip.fetch_tip(name)
389
Kurt B. Kaiserb1754452005-11-18 22:05:48 +0000390 def get_the_completion_list(self, what, mode):
391 return self.autocomplete.fetch_completions(what, mode)
392
Chui Tey5d2af632002-05-26 13:36:41 +0000393 def stackviewer(self, flist_oid=None):
Kurt B. Kaiser9f366092003-06-02 01:50:19 +0000394 if self.usr_exc_info:
395 typ, val, tb = self.usr_exc_info
396 else:
Chui Tey5d2af632002-05-26 13:36:41 +0000397 return None
398 flist = None
399 if flist_oid is not None:
Kurt B. Kaiserffd3a422002-06-26 02:32:09 +0000400 flist = self.rpchandler.get_remote_proxy(flist_oid)
Chui Tey5d2af632002-05-26 13:36:41 +0000401 while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]:
402 tb = tb.tb_next
Kurt B. Kaiser9f366092003-06-02 01:50:19 +0000403 sys.last_type = typ
404 sys.last_value = val
Chui Tey5d2af632002-05-26 13:36:41 +0000405 item = StackViewer.StackTreeItem(flist, tb)
406 return RemoteObjectBrowser.remote_object_tree_item(item)
Terry Jan Reedy95a3f112013-06-28 23:50:12 -0400407
408capture_warnings(False) # Make sure turned off; see issue 18081