[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#673586: FTBFS if Python 3.2 is installed in chroot



Package: lsb
Version: 4.1+Debian9
Followup-For: Bug #673586
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu saucy ubuntu-patch

Hi guys,

The latest version of lsb is /almost/ compatible with python3 at build-time. 
Just one test still fails under python3.x, because initdutils.py has not
been ported to python3.  It's fairly easy to fix this up for python3
compatibility (via 2to3 or otherwise).  Please find attached the patch that
fixes the remaining problem.

As Ubuntu uses python3, not python2, in its base system, we are building
lsb against python3.  So this patch will be included in Ubuntu shortly.

Thanks for considering the patch.

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slangasek@ubuntu.com                                     vorlon@debian.org
=== modified file 'initdutils.py'
--- initdutils.py	2008-08-18 16:34:24 +0000
+++ initdutils.py	2013-05-15 07:57:15 +0000
@@ -1,13 +1,10 @@
 # Support for scanning init scripts for LSB info
 
-import re, sys, os, cStringIO
-import cPickle
+# Python3-compatible print() function
+from __future__ import print_function
 
-try:
-    assert True
-except:
-    True = 1
-    False = 0
+import re, sys, os, io
+import pickle
 
 class RFC822Parser(dict):
     "A dictionary-like object."
@@ -15,14 +12,14 @@
     
     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 = io.StringIO(strob)
 
         key = None
         for line in fileob:
@@ -108,7 +105,7 @@
         if facility.startswith('$'): continue
         for (scriptname, pri) in entries.items():
             start, stop = pri
-            print >> fh, "%(scriptname)s %(facility)s %(start)d %(stop)d" % locals()
+            print("%(scriptname)s %(facility)s %(start)d %(stop)d" % locals(), file=fh)
     fh.close()
 
 def load_facilities():
@@ -119,8 +116,8 @@
                 scriptname, name, start, stop = line.strip().split()
                 facilities.setdefault(name, {})[scriptname] = (int(start),
                                                                int(stop))
-            except ValueError, x:
-                print >> sys.stderr, 'Invalid facility line', line
+            except ValueError as x:
+                print('Invalid facility line', line, file=sys.stderr)
 
     return facilities
 
@@ -143,7 +140,7 @@
     
     fh = file(DEPENDS, 'w')
     for initfile, facilities in depends.iteritems():
-        print >> fh, '%s: %s' % (initfile, ' '.join(facilities))
+        print('%s: %s' % (initfile, ' '.join(facilities)), fh)
     fh.close()
 
 # filemap entries are mappings, { (package, filename) : instloc }
@@ -152,7 +149,7 @@
         return {}
     
     fh = open(LSBINSTALL, 'rb')
-    filemap = cPickle.load(fh)
+    filemap = pickle.load(fh)
     fh.close()
 
     # Just in case it's corrupted somehow
@@ -170,8 +167,8 @@
         return
     
     fh = open(LSBINSTALL, 'wb')
-    cPickle.dump(fh, filemap)
+    pickle.dump(fh, filemap)
     fh.close()
 
 if __name__ == '__main__':
-    print scan_initfile('init-fragment')
+    print(scan_initfile('init-fragment'))


Reply to: