Fix initdutils for Python 3 compatibility.
authorJeff Licquia <jeff@virtpc-wheezy.internal.licquia.org>
Sun, 15 Jul 2012 19:09:37 +0000 (15:09 -0400)
committerDidier Raboud <odyx@debian.org>
Mon, 5 Nov 2012 11:07:24 +0000 (12:07 +0100)
debian/changelog
initdutils.py

index ec74ec198df3e46f11d8c6f8c9b0e3bbb0ad14e3..28ffea887c22261f322543371ac3b5f852950d6f 100644 (file)
@@ -1,3 +1,9 @@
+lsb (4.1+Debian9) UNRELEASED; urgency=low
+
+  * Fix initdutils for compatibility with Python 3.
+
+ -- Jeff Licquia <licquia@debian.org>  Sun, 15 Jul 2012 15:08:26 -0400
+
 lsb (4.1+Debian8) unstable; urgency=low
 
   * Fix libqt3-mt missing epoch.
index 3b5bb107e947718f645a03cd2e9789727728b31d..0451b185792ce5c259860d54955d892c71895afe 100644 (file)
@@ -1,13 +1,12 @@
 # Support for scanning init scripts for LSB info
 
-import re, sys, os, cStringIO
-import cPickle
+import re, sys, os
+import pickle
 
 try:
-    assert True
-except:
-    True = 1
-    False = 0
+    from io import StringIO
+except ImportError:
+    from cStringIO import StringIO
 
 class RFC822Parser(dict):
     "A dictionary-like object."
@@ -15,14 +14,14 @@ class RFC822Parser(dict):
     
     def __init__(self, fileob=None, strob=None, startcol=0, basedict=None):
         if not fileob and not strob:
-            raise ValueError, 'need a file or string'
+            raise ValueError('need a file or string')
         if not basedict:
             basedict = {}
         
         super(RFC822Parser, self).__init__(basedict)
 
         if not fileob:
-            fileob = cStringIO.StringIO(strob)
+            fileob = StringIO(strob)
 
         key = None
         for line in fileob:
@@ -119,7 +118,7 @@ def load_facilities():
                 scriptname, name, start, stop = line.strip().split()
                 facilities.setdefault(name, {})[scriptname] = (int(start),
                                                                int(stop))
-            except ValueError, x:
+            except ValueError as x:
                 print >> sys.stderr, 'Invalid facility line', line
 
     return facilities
@@ -174,4 +173,4 @@ def save_lsbinstall_info(filemap):
     fh.close()
 
 if __name__ == '__main__':
-    print scan_initfile('init-fragment')
+    print (scan_initfile('init-fragment'))