Commits

Floris Bruynooghe  committed 59b9085

Add MibInstrumController traceback patch.

  • Participants
  • Parent commits 271b063

Comments (0)

Files changed (2)

File instrum_tracebacks

+# HG changeset patch
+# Parent 2f2f33cd9cf3aa451928296796720a30124727a7
+# User Floris Bruynooghe <flub@devork.be>
+# Date 1324248510 -3600
+
+Improve the tracebacks propagated from the MibInstrumController
+
+By just saving the exception type from exceptions in the SMI
+instrumentation it is hard to track the problem to it's source.  This
+patch saves the entire exception with it's value and traceback, but
+still avoids creating reference counting cycles.
+
+
+diff --git a/pysnmp/smi/instrum.py b/pysnmp/smi/instrum.py
+--- a/pysnmp/smi/instrum.py
++++ b/pysnmp/smi/instrum.py
+@@ -211,7 +211,7 @@ class MibInstrumController:
+                 except error.SmiError:
+                     debug.logger & debug.flagIns and debug.logger('flipFlopFsm: fun %s failed %s for %s=%r' % (f, sys.exc_info()[1], name, val))
+                     if myErr is None:  # Take the first exception
+-                        myErr = sys.exc_info()[1]
++                        myErr = sys.exc_info()
+                     status = 'err'
+                     break
+                 else:
+@@ -220,7 +220,11 @@ class MibInstrumController:
+                         outputNameVals.append((rval[0], rval[1]))
+                 idx = idx + 1
+         if myErr:
+-            raise myErr
++            try:
++                raise myErr[0], myErr[1], myErr[2]
++            finally:
++                # Break cycle between locals and traceback object
++                del myErr
+         return outputNameVals
+     
+     def readVars(self, vars, acInfo=(None, None)):
 zipmibsource_import
 zipimport_bytecode
+instrum_tracebacks
 # Placed by Bitbucket