diff options
author | Ilya Etingof <etingof@gmail.com> | 2018-10-26 08:34:26 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2018-10-26 08:45:46 +0200 |
commit | 4aac8b23d50012979730557786b2962b185bd9c3 (patch) | |
tree | 10a6bdac33aaeedab2ad8e7556f03613f6495ad1 /pysnmp/smi | |
parent | 602c4dd30463b64f42f5ddd70d601ff672f6d0ce (diff) | |
download | pysnmp-git-4aac8b23d50012979730557786b2962b185bd9c3.tar.gz |
Use `compile()` before `exec` of MIB modules
This change attaches the file name to the stack frames
what is helpful when reading traceback or debugging
interactively.
Diffstat (limited to 'pysnmp/smi')
-rw-r--r-- | pysnmp/smi/builder.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pysnmp/smi/builder.py b/pysnmp/smi/builder.py index f68ccc65..2e6701f2 100644 --- a/pysnmp/smi/builder.py +++ b/pysnmp/smi/builder.py @@ -263,7 +263,7 @@ class MibBuilder(object): self.mibSymbols = {} self.__mibSources = [] self.__modSeen = {} - self.__modPathsSeen = {} + self.__modPathsSeen = set() self.__mibCompiler = None self.setMibSources(*sources) @@ -306,19 +306,19 @@ class MibBuilder(object): debug.logger & debug.flagBld and debug.logger('loadModule: seen %s' % modPath) break else: - self.__modPathsSeen[modPath] = 1 + self.__modPathsSeen.add(modPath) debug.logger & debug.flagBld and debug.logger('loadModule: evaluating %s' % modPath) g = {'mibBuilder': self, 'userCtx': userCtx} try: - exec (modData, g) + exec(compile(modData, modPath, 'exec'), g) except Exception: del self.__modPathsSeen[modPath] raise error.MibLoadError( - 'MIB module \"%s\" load error: %s' % (modPath, traceback.format_exception(*sys.exc_info())) + 'MIB module \'%s\' load error: %s' % (modPath, traceback.format_exception(*sys.exc_info())) ) self.__modSeen[modName] = modPath |