From 2a5bb842665d68772dd45c1a25b43412737aa810 Mon Sep 17 00:00:00 2001 From: Jeff Licquia Date: Sun, 15 Jul 2012 15:09:37 -0400 Subject: [PATCH] Fix initdutils for Python 3 compatibility. --- debian/changelog | 6 ++++++ initdutils.py | 19 +++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index ae2b699..2ff9467 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +lsb (4.1+Debian8) UNRELEASED; urgency=low + + * Fix initdutils for compatibility with Python 3. + + -- Jeff Licquia Sun, 15 Jul 2012 15:08:26 -0400 + lsb (4.1+Debian7) unstable; urgency=low * lsb-desktop: Demote Qt3 dependency to a Recommends. Closes: #604360 diff --git a/initdutils.py b/initdutils.py index 3b5bb10..0451b18 100644 --- a/initdutils.py +++ b/initdutils.py @@ -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')) -- 2.30.2