hi,

I attach a patch that works for me.

It removes dangling symlinks and the associated compiled files. 
Maybe this is too drakonian... if you think so, just comment out
the 'unlink' lines

a.

-- 
Andrea Mennucc

"The EULA sounds like it was written by a team of lawyers who want to tell 
me what I can't do, and the GPL sounds like it was written by a human 
being who wants me to know what I can do."
Anonymous,    http://www.securityfocus.com/columnists/420
--- /tmp/pycompile	2011-01-10 14:00:44.000000000 +0100
+++ /usr/bin/pycompile	2011-01-10 14:07:50.000000000 +0100
@@ -28,8 +28,8 @@
 import optparse
 import os
 import sys
-from os import environ, listdir, walk
-from os.path import abspath, exists, isdir, isfile, join
+from os import environ, listdir, walk, unlink
+from os.path import abspath, exists, isdir, isfile, islink, join
 from subprocess import PIPE, STDOUT, Popen
 sys.path.insert(1, '/usr/share/python/')
 from debpython.version import SUPPORTED, debsorted, vrepr, \
@@ -192,6 +192,13 @@
     # byte compile files
     for fn, versions_to_compile in filter_files(files, e_patterns, versions):
         cfn = fn + 'c' if (__debug__ or not optimize) else 'o'
+        if islink(fn) and not exists(fn):
+            log.warn('Removing broken symlink: %s', fn)
+            unlink(fn)
+            if exists(cfn) and isfile(cfn):
+                log.warn('Removing associated compiled file: %s', cfn)
+                unlink(cfn)
+            continue
         if exists(cfn) and not force:
             ftime = os.stat(fn).st_mtime
             try:

Reply via email to