diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2007-07-14 21:56:19 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2007-07-14 21:56:19 (GMT) |
commit | 2b09ef0c6d8db26ff6c6c10d94130936b11783da (patch) | |
tree | 916681a97a36efe246bc07a86aa2ec91551cf6c2 /Lib/mailbox.py | |
parent | 6111ce36670d79055d0e357acf246ded39f84529 (diff) | |
download | cpython-2b09ef0c6d8db26ff6c6c10d94130936b11783da.zip cpython-2b09ef0c6d8db26ff6c6c10d94130936b11783da.tar.gz cpython-2b09ef0c6d8db26ff6c6c10d94130936b11783da.tar.bz2 |
Avoid exception if there's a stray directory inside a Maildir folder.
The Maildir specification doesn't seem to say anything about this
situation, and it can happen if you're keeping a Maildir mailbox in
Subversion (.svn directories) or some similar system. The patch just
ignores directories in the cur/, new/, tmp/ folders.
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-x | Lib/mailbox.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index 520afeb..3f7a12a 100755 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -459,7 +459,11 @@ class Maildir(Mailbox): """Update table of contents mapping.""" self._toc = {} for subdir in ('new', 'cur'): - for entry in os.listdir(os.path.join(self._path, subdir)): + subdir_path = os.path.join(self._path, subdir) + for entry in os.listdir(subdir_path): + p = os.path.join(subdir_path, entry) + if os.path.isdir(p): + continue uniq = entry.split(self.colon)[0] self._toc[uniq] = os.path.join(subdir, entry) |