[Checkins] SVN: zope.testing/trunk/ make directory cleanup resiliant in the face of broken symlinks

Fred Drake fdrake at gmail.com
Mon Nov 29 16:35:02 EST 2010


Log message for revision 118637:
  make directory cleanup resiliant in the face of broken symlinks

Changed:
  U   zope.testing/trunk/CHANGES.txt
  U   zope.testing/trunk/src/zope/testing/setupstack.py
  U   zope.testing/trunk/src/zope/testing/setupstack.txt

-=-
Modified: zope.testing/trunk/CHANGES.txt
===================================================================
--- zope.testing/trunk/CHANGES.txt	2010-11-29 09:43:06 UTC (rev 118636)
+++ zope.testing/trunk/CHANGES.txt	2010-11-29 21:35:01 UTC (rev 118637)
@@ -1,10 +1,10 @@
 zope.testing Changelog
 **********************
 
-3.10.1 (unreleased)
+3.10.1 (2010-11-29)
 ===================
 
-- Nothing changed yet.
+- Fix removal of broken symlinks on Unix.
 
 
 3.10.0 (2010-07-21)

Modified: zope.testing/trunk/src/zope/testing/setupstack.py
===================================================================
--- zope.testing/trunk/src/zope/testing/setupstack.py	2010-11-29 09:43:06 UTC (rev 118636)
+++ zope.testing/trunk/src/zope/testing/setupstack.py	2010-11-29 21:35:01 UTC (rev 118637)
@@ -43,7 +43,8 @@
     for path, dirs, files in os.walk(path, False):
         for fname in files:
             fname = os.path.join(path, fname)
-            os.chmod(fname, stat.S_IWUSR)
+            if not os.path.islink(fname):
+                os.chmod(fname, stat.S_IWUSR)
             os.remove(fname)
         for dname in dirs:
             dname = os.path.join(path, dname)

Modified: zope.testing/trunk/src/zope/testing/setupstack.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/setupstack.txt	2010-11-29 09:43:06 UTC (rev 118636)
+++ zope.testing/trunk/src/zope/testing/setupstack.txt	2010-11-29 21:35:01 UTC (rev 118637)
@@ -87,6 +87,12 @@
     >>> import stat
     >>> os.chmod('Data.fs', stat.S_IREAD)
 
+On Unix systems, broken symlinks can cause problems because the chmod
+attempt by the teardown hook will fail; let's set up a broken symlink as
+well, and verify the teardown doesn't break because of that:
+
+    >>> os.symlink('NotThere', 'BrokenLink')
+
 When tearDown is called:
 
     >>> zope.testing.setupstack.tearDown(test)



More information about the checkins mailing list