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

Bug#585254: mklibs: Python string exceptions no more allowed in Python 2.6



reassign 585257 src:mklibs reassign 585254 src:mklibs forcemerge 585254 585257
tags 585254 + patch
thanks

* Sandro Tosi <morph@debian.org>, 2010-06-09, 22:19:
One of the changes brought by Python 2.6 is the removal of string
exceptions, so they won't work in Python 2.6 (just a side note: they
were also buggy before, since they were not guaranteed to work
reliable even in <2.6); as an example:

$ python2.5 -c "raise 'eggs'"
-c:1: DeprecationWarning: raising a string exception is deprecated
Traceback (most recent call last):
 File "<string>", line 1, in <module>
eggs

$ python2.6 -c "raise 'eggs'"
Traceback (most recent call last):
 File "<string>", line 1, in <module>
TypeError: exceptions must be old-style classes or derived from BaseException, not str

The attached patch fixes these bugs.

--
Jakub Wilk
diff -Nru mklibs-0.1.30/src/mklibs mklibs-0.1.30+nmu1/src/mklibs
--- mklibs-0.1.30/src/mklibs	2010-06-02 19:47:32.000000000 +0200
+++ mklibs-0.1.30+nmu1/src/mklibs	2010-08-08 14:18:06.000000000 +0200
@@ -85,7 +85,7 @@
 
 def elf_header(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     output = command("mklibs-readelf", "--print-elf-header", obj)
     s = [int(i) for i in output[0].split()]
     return {'class': s[0], 'data': s[1], 'machine': s[2], 'flags': s[3]}
@@ -93,21 +93,21 @@
 # Return a set of rpath strings for the passed object
 def rpath(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     output = command("mklibs-readelf", "--print-rpath", obj)
     return [root + "/" + x for x in output]
 
 # Return a set of libraries the passed objects depend on.
 def library_depends(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     return command("mklibs-readelf", "--print-needed", obj)
 
 # Return a list of libraries the passed objects depend on. The
 # libraries are in "-lfoo" format suitable for passing to gcc.
 def library_depends_gcc_libnames(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     libs = library_depends(obj)
     ret = []
     for i in libs:
@@ -139,7 +139,7 @@
 # Return undefined symbols in an object as a set of tuples (name, weakness)
 def undefined_symbols(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib" + obj
+        raise Exception("Cannot find lib" + obj)
 
     output = command("mklibs-readelf", "--print-symbols-undefined", obj)
 
@@ -194,7 +194,7 @@
 # Return a set of symbols provided by a library
 def provided_symbols(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib" + obj
+        raise Exception("Cannot find lib" + obj)
     library = extract_soname(obj)
 
     output = command("mklibs-readelf", "--print-symbols-provided", obj)
@@ -500,7 +500,7 @@
         # No progress in last pass. Verify all remaining symbols are weak.
         for name in unresolved:
             if not needed_symbols[name].weak:
-                raise "Unresolvable symbol %s" % name
+                raise Exception("Unresolvable symbol %s" % name)
         break
 
     previous_pass_unresolved = unresolved
@@ -535,7 +535,7 @@
     for name in needed_symbols:
         if not name in symbol_provider:
             if not needed_symbols[name].weak:
-                raise "No library provides non-weak %s" % name
+                raise Exception("No library provides non-weak %s" % name)
         else:
             lib = symbol_provider[name]
             library_symbols_used[lib].add(library_symbols[lib][name])
diff -Nru mklibs-0.1.30/src/mklibs-copy mklibs-0.1.30+nmu1/src/mklibs-copy
--- mklibs-0.1.30/src/mklibs-copy	2010-06-02 19:47:32.000000000 +0200
+++ mklibs-0.1.30+nmu1/src/mklibs-copy	2010-08-08 14:19:12.000000000 +0200
@@ -70,7 +70,7 @@
 
 def elf_header(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     output = command("mklibs-readelf", "--print-elf-header", obj)
     s = [int(i) for i in output[0].split()]
     return {'class': s[0], 'data': s[1], 'machine': s[2], 'flags': s[3]}
@@ -78,14 +78,14 @@
 # Return a set of rpath strings for the passed object
 def rpath(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     output = command("mklibs-readelf", "-R", obj)
     return [root + "/" + x for x in output if x]
 
 # Return a set of libraries the passed objects depend on.
 def library_depends(obj):
     if not os.access(obj, os.F_OK):
-        raise "Cannot find lib: " + obj
+        raise Exception("Cannot find lib: " + obj)
     return [x for x in command("mklibs-readelf", "-n", obj) if x]
 
 # Return real target of a symlink

Attachment: signature.asc
Description: Digital signature


Reply to: