diff options
Diffstat (limited to 'pysnmp/smi/builder.py')
-rw-r--r-- | pysnmp/smi/builder.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pysnmp/smi/builder.py b/pysnmp/smi/builder.py index fd61d872..e7cf02f2 100644 --- a/pysnmp/smi/builder.py +++ b/pysnmp/smi/builder.py @@ -139,7 +139,10 @@ class ZipMibSource(__AbstractMibSource): raise IOError('No file in ZIP: %s' % p) def _getData(self, f, mode=None): - return self.__loader.get_data(os.path.join(self._srcName, f)).replace('\r\n', '\n') + data = self.__loader.get_data(os.path.join(self._srcName, f)) + if sys.version_info[0] <= 2: + data = data.replace('\r\n', '\n') + return data class DirMibSource(__AbstractMibSource): def _init(self): @@ -158,7 +161,10 @@ class DirMibSource(__AbstractMibSource): def _getData(self, f, mode): try: if f in os.listdir(self._srcName): # make FS case-sensitive - return open(os.path.join(self._srcName, f), mode).read().replace('\r\n', '\n') + data = open(os.path.join(self._srcName, f), mode).read() + if sys.version_info[0] <= 2: + data = data.replace('\r\n', '\n') + return data except OSError: pass raise IOError # pretend there's no such file |