tags 400001 + patch
thanks

Hi,

Attached is a possible patch to fix this issue. I tested it here by
creating an error in a private module:
$ sudo /var/lib/dpkg/info/linda.postinst configure
WARNING: compile error while trying to byte-compile 
/usr/share/linda/checks/shebang.py:   File 
"/usr/share/linda/checks/shebang.py", line 4
    ; + beur
    ^
SyntaxError: invalid syntax

(sid) [EMAIL PROTECTED]:~/local/debian$ echo $?
0

Note however that the problem only existed with private modules since the
public modules are byte-compiled by compile_all which is spawned as a
separate process and whose return value we don't check. However the process
displays similar warnings.

For consistency of output I decided to ask compile() to raise an exception but
in fact it's not really needed. I could have checked only the IOError
exception (or only the generic one).

Feel free to adapt to suit your needs.

Cheers,
-- 
Raphaël Hertzog

Premier livre français sur Debian GNU/Linux :
http://www.ouaza.com/livre/admin-debian/
diff -Nru /tmp/9tKXsR3naN/python-support-0.5.5/debian/changelog 
/tmp/9DkRb9y0Lf/python-support-0.5.6/debian/changelog
--- /tmp/9tKXsR3naN/python-support-0.5.5/debian/changelog       2006-11-14 
21:27:26.000000000 +0100
+++ /tmp/9DkRb9y0Lf/python-support-0.5.6/debian/changelog       2006-11-23 
14:12:08.000000000 +0100
@@ -1,3 +1,11 @@
+python-support (0.5.6) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Don't raise IOError while trying to byte-compile an *.py file (for example,
+    when the file is a symlink to a non-existent file). Closes: #400001
+
+ -- Raphael Hertzog <[EMAIL PROTECTED]>  Thu, 23 Nov 2006 14:10:25 +0100
+
 python-support (0.5.5) unstable; urgency=high
 
   * dh_pysupport, pysupport-movemodules, debian/rules, 
diff -Nru /tmp/9tKXsR3naN/python-support-0.5.5/update-python-modules 
/tmp/9DkRb9y0Lf/python-support-0.5.6/update-python-modules
--- /tmp/9tKXsR3naN/python-support-0.5.5/update-python-modules  2006-09-22 
21:12:04.000000000 +0200
+++ /tmp/9DkRb9y0Lf/python-support-0.5.6/update-python-modules  2006-11-23 
14:19:45.000000000 +0100
@@ -6,7 +6,7 @@
 
 import sys,os,os.path
 from optparse import OptionParser
-from py_compile import compile
+from py_compile import compile, PyCompileError
 
 basepath='/var/lib/python-support'
 sourcepath='/usr/share/python-support'
@@ -87,7 +87,15 @@
   if file.endswith('.py'):
     fullpath=os.path.join(basedir,dir,file)
     debug("compile "+fullpath+'c')
-    compile(fullpath)
+    try:
+      # Not that compile doesn't raise PyCompileError by default
+      compile(fullpath, doraise=True)
+    except IOError, (errno, strerror):
+      print >>sys.stderr, "WARNING: I/O error while trying to byte-compile %s 
(%s): %s" % (fullpath, errno, strerror)
+    except PyCompileError, inst:
+      print >>sys.stderr, "WARNING: compile error while trying to byte-compile 
%s: %s" % (fullpath, inst.msg)
+    except:
+      print >>sys.stderr, "WARNING: unexpected error while trying to 
byte-compile %s: %s" % (fullpath, sys.exc_info()[0])
 
 def clean_simple(basedir,dir,file):
   if file.endswith('.py'):

Reply via email to