pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/3f5eb3e6c75b874db1a83c9d53e824e56fcad02e

bpo-21360: mailbox.Maildir now ignores files with a leading dot (GH-1… · python/cpython@3f5eb3e · GitHub
Skip to content

Commit 3f5eb3e

Browse files
bpo-21360: mailbox.Maildir now ignores files with a leading dot (GH-11833)
The maildir format specification states that files with a leading dot should be ignored. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent f7c5a7a commit 3f5eb3e

5 files changed

Lines changed: 23 additions & 0 deletions

File tree

Doc/library/mailbox.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
364364

365365
The :attr:`!colon` attribute may also be set on a per-instance basis.
366366

367+
.. versionchanged:: 3.13
368+
:class:`Maildir` now ignores files with a leading dot.
369+
367370
:class:`!Maildir` instances have all of the methods of :class:`Mailbox` in
368371
addition to the following:
369372

Doc/whatsnew/3.13.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,9 @@ Changes in the Python API
11631163
other "private" attributes.
11641164
(See :gh:`112826`.)
11651165

1166+
* :class:`mailbox.Maildir` now ignores files with a leading dot.
1167+
(Contributed by Zackery Spytz in :gh:`65559`.)
1168+
11661169

11671170
Build Changes
11681171
=============

Lib/mailbox.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ def _refresh(self):
590590
for subdir in self._toc_mtimes:
591591
path = self._paths[subdir]
592592
for entry in os.listdir(path):
593+
if entry.startswith('.'):
594+
continue
593595
p = os.path.join(path, entry)
594596
if os.path.isdir(p):
595597
continue

Lib/test/test_mailbox.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,20 @@ def test_initialize_existing(self):
681681
self._box = mailbox.Maildir(self._path)
682682
self._check_basics()
683683

684+
def test_filename_leading_dot(self):
685+
self.tearDown()
686+
for subdir in '', 'tmp', 'new', 'cur':
687+
os.mkdir(os.path.normpath(os.path.join(self._path, subdir)))
688+
for subdir in 'tmp', 'new', 'cur':
689+
fname = os.path.join(self._path, subdir, '.foo' + subdir)
690+
with open(fname, 'wb') as f:
691+
f.write(b"@")
692+
self._box = mailbox.Maildir(self._path)
693+
self.assertNotIn('.footmp', self._box)
694+
self.assertNotIn('.foonew', self._box)
695+
self.assertNotIn('.foocur', self._box)
696+
self.assertEqual(list(self._box.iterkeys()), [])
697+
684698
def _check_basics(self, factory=None):
685699
# (Used by test_open_new() and test_open_existing().)
686700
self.assertEqual(self._box._path, os.path.abspath(self._path))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:class:`mailbox.Maildir` now ignores files with a leading dot.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy