]> granicus.if.org Git - python/commitdiff
Patch #707167: Pass dircache exceptions to the caller. Fixes #682813.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 20 Sep 2003 15:52:21 +0000 (15:52 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 20 Sep 2003 15:52:21 +0000 (15:52 +0000)
Not backported because of behaviour change.

Doc/whatsnew/whatsnew24.tex
Lib/dircache.py
Lib/test/test_dircache.py
Misc/NEWS

index 2f0df30fe172692a30b3bb0f7b4b0ee7b6ff8398..5fda620e4563ce5d23e13374348c11a4923dd9df 100644 (file)
@@ -124,7 +124,8 @@ changes to your code:
 
 \begin{itemize}
 
-\item Everything is all in the details!
+\item dircache.listdir now passes exceptions to the caller, 
+instead of returning empty lists.
 
 \end{itemize}
 
index e18c7c37a4e98062bfb25b4e434e7f99b8811d10..78ec7fe0f433b3ac535761e147da158569b97ac3 100644 (file)
@@ -22,15 +22,9 @@ def listdir(path):
         del cache[path]
     except KeyError:
         cached_mtime, list = -1, []
-    try:
-        mtime = os.stat(path).st_mtime
-    except os.error:
-        return []
+    mtime = os.stat(path).st_mtime
     if mtime != cached_mtime:
-        try:
-            list = os.listdir(path)
-        except os.error:
-            return []
+        list = os.listdir(path)
         list.sort()
     cache[path] = mtime, list
     return list
index 2ec89a2dadf04739c298cc9a47fda7a7e6a40f5b..52014e2e9ef1a3c578e4d05dbfe0c6eb239558da 100644 (file)
@@ -56,7 +56,7 @@ class DircacheTests(unittest.TestCase):
             self.assert_(dircache.listdir(self.tempdir) is entries)
 
         ## UNSUCCESSFUL CASES
-        self.assertEquals(dircache.listdir(self.tempdir+"_nonexistent"), [])
+        self.assertRaises(OSError, dircache.listdir, self.tempdir+"_nonexistent")
 
     def test_annotate(self):
         self.writeTemp("test2")
index 7ffe5217685c14be0a08b859b27bafdaf4f3e648..2f0aec87a317ed8cfd6d8d01b4cb1c71d9b7d11b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,9 @@ Extension modules
 Library
 -------
 
+- dircache now passes exceptions to the caller, instead of returning
+  empty lists.
+
 - The bsddb module and dbhash module now support the iterator and
   mapping protocols which make them more substitutable for dictionaries
   and shelves.