summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-09-20 15:52:21 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-09-20 15:52:21 (GMT)
commitc6bb6c0f8c90f5f14d933b974db4c3ce2c7b296f (patch)
tree9a27b32b9463ffbd3264800ac7f138022f58f685
parenta64988c001d21335d47451586654702caec8aa1f (diff)
downloadcpython-c6bb6c0f8c90f5f14d933b974db4c3ce2c7b296f.zip
cpython-c6bb6c0f8c90f5f14d933b974db4c3ce2c7b296f.tar.gz
cpython-c6bb6c0f8c90f5f14d933b974db4c3ce2c7b296f.tar.bz2
Patch #707167: Pass dircache exceptions to the caller. Fixes #682813.
Not backported because of behaviour change.
-rw-r--r--Doc/whatsnew/whatsnew24.tex3
-rw-r--r--Lib/dircache.py10
-rw-r--r--Lib/test/test_dircache.py2
-rw-r--r--Misc/NEWS3
4 files changed, 8 insertions, 10 deletions
diff --git a/Doc/whatsnew/whatsnew24.tex b/Doc/whatsnew/whatsnew24.tex
index 2f0df30..5fda620 100644
--- a/Doc/whatsnew/whatsnew24.tex
+++ b/Doc/whatsnew/whatsnew24.tex
@@ -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}
diff --git a/Lib/dircache.py b/Lib/dircache.py
index e18c7c3..78ec7fe 100644
--- a/Lib/dircache.py
+++ b/Lib/dircache.py
@@ -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
diff --git a/Lib/test/test_dircache.py b/Lib/test/test_dircache.py
index 2ec89a2..52014e2 100644
--- a/Lib/test/test_dircache.py
+++ b/Lib/test/test_dircache.py
@@ -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")
diff --git a/Misc/NEWS b/Misc/NEWS
index 7ffe521..2f0aec8 100644
--- 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.