[gedit-plugins] Improved traceback for module execution in commander
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Improved traceback for module execution in commander
- Date: Sat, 27 Aug 2011 08:39:57 +0000 (UTC)
commit fd90966d7c5b1139e089a5e97f0a2c668cabe4b3
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Sat Aug 27 10:39:30 2011 +0200
Improved traceback for module execution in commander
plugins/commander/commander/entry.py | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/plugins/commander/commander/entry.py b/plugins/commander/commander/entry.py
index b1fedae..10f2a1f 100644
--- a/plugins/commander/commander/entry.py
+++ b/plugins/commander/commander/entry.py
@@ -24,6 +24,7 @@ import cairo
import os
import re
import inspect
+import sys
import commander.commands as commands
import commands.completion
@@ -397,7 +398,7 @@ GtkEntry#gedit-commander-entry {
self.info_show('<b><span color="#f66">Error:</span></b> ' + saxutils.escape(str(e)), True)
if not isinstance(e, commands.exceptions.Execute):
- self.info_show(traceback.format_exc(), False)
+ self.info_show(self.format_trace(), False)
return None
@@ -423,6 +424,33 @@ GtkEntry#gedit-commander-entry {
return ret
+ def format_trace(self):
+ tp, val, tb = sys.exc_info()
+
+ origtb = tb
+
+ thisdir = os.path.dirname(__file__)
+
+ # Skip frames up until after the last entry.py...
+ while True:
+ filename = tb.tb_frame.f_code.co_filename
+
+ dname = os.path.dirname(filename)
+
+ if not dname.startswith(thisdir):
+ break
+
+ tb = tb.tb_next
+
+ msg = traceback.format_exception(tp, val, tb)
+ r = ''.join(msg[0:-1])
+
+ # This is done to prevent cyclic references, see python
+ # documentation on sys.exc_info
+ del origtb
+
+ return r
+
def on_execute(self, dummy, modifier):
if self._info_window and not self._suspended:
self._info_window.destroy()
@@ -646,4 +674,4 @@ GtkEntry#gedit-commander-entry {
self._history.save()
-# vi:ex:ts=4:et
+# vi:ex:ts=4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]