From 0b76c9a515c320d675110d5be92b80923edb07ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Mon, 10 Jan 2011 23:08:30 +0100
Subject: [PATCH] pycompile: skip dangling symlinks

---
 debian/changelog |  5 +++--
 pycompile        | 10 ++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 87ba1f7..7404d34 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,11 @@
-python-defaults (2.6.6-10) UNRELEASED; urgency=low
+python-defaults (2.6.6-10) experimental; urgency=low
 
   * dh_python2: fix moving files from old debug locations (due to typo)
   * python-minimal now Breaks python-support << 1.0.12 (Python 2.7 support was
     added in 1.0.12)
+  * pycompile: skip dangling symlinks
 
- -- Piotr OĹźarowski <piotr@debian.org>  Thu, 06 Jan 2011 16:12:25 +0100
+ -- Piotr OĹźarowski <piotr@debian.org>  Mon, 10 Jan 2011 23:05:47 +0100
 
 python-defaults (2.6.6-9) experimental; urgency=low
 
diff --git a/pycompile b/pycompile
index 544a979..de28868 100755
--- a/pycompile
+++ b/pycompile
@@ -29,7 +29,7 @@ import optparse
 import os
 import sys
 from os import environ, listdir, walk
-from os.path import abspath, exists, isdir, isfile, join
+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,13 +192,19 @@ def compile(files, versions, force, optimize, e_patterns=None):
     # 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 not exists(fn):
+            # pycentral's hook should clean it later
+            if islink(fn):
+                log.warn('dangling symlink skipped: %s (%s)', fn,
+                          os.readlink(fn))
+            continue
         if exists(cfn) and not force:
             ftime = os.stat(fn).st_mtime
             try:
                 ctime = os.stat(cfn).st_mtime
             except os.error:
                 ctime = 0
-            if (ctime > ftime):
+            if ctime > ftime:
                 continue
         for version in versions_to_compile:
             try:
-- 
GitLab