This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mailbox should test for errno.EROFS
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: matt, orsenthil, r.david.murray
Priority: normal Keywords:

Created on 2011-02-24 07:03 by matt, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg129252 - (view) Author: Matt Johnston (matt) Date: 2011-02-24 07:03
When opening mailboxes the module checks for errno.EACCES. This doesn't help if the location is mounted read-only. Something like the following (against Python 2.6) would fix it, there are a few other checks in mailbox.py for EACCES too.

--- mailbox.py.orig	2011-02-24 15:02:22.000000000 +0800
+++ mailbox.py	2011-02-24 15:02:05.000000000 +0800
@@ -512,7 +512,7 @@ class _singlefileMailbox(Mailbox):
                     f = open(self._path, 'wb+')
                 else:
                     raise NoSuchMailboxError(self._path)
-            elif e.errno == errno.EACCES:
+            elif e.errno == errno.EACCES or e.errno == errno.EROFS:
                 f = open(self._path, 'rb')
             else:
                 raise
msg129268 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-02-24 15:07
Creating a test for this may not be practical :(
msg129738 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-03-01 03:17
On Thu, Feb 24, 2011 at 03:07:10PM +0000, R. David Murray wrote:
> Creating a test for this may not be practical :(

Then should we just go ahead with this change as it seems reasonable
one.

-            elif e.errno == errno.EACCES:                                                                                                                             
+            elif e.errno == errno.EACCES or e.errno == errno.EROFS:
msg129986 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-03-03 18:19
Committed to py3k in r88730, 3.2 in r88731, and 2.7 in r88732.

I tested it by hand; mbox open failed before patch, succeeded (read-only) after patch.  I also changed two other cases of EACCES tests without testing them; I don't see how it could hurt to add EROFS.  I did not touch the os2-specific cases as there it looks like EROFS might require a different semantic from EACCES.
History
Date User Action Args
2022-04-11 14:57:13adminsetgithub: 55515
2011-03-03 18:19:25r.david.murraysetstatus: open -> closed
versions: + Python 2.7, Python 3.2
nosy: orsenthil, matt, r.david.murray
messages: + msg129986

resolution: fixed
stage: needs patch -> resolved
2011-03-01 03:17:49orsenthilsetnosy: + orsenthil
messages: + msg129738
2011-02-24 15:07:08r.david.murraysetnosy: + r.david.murray
messages: + msg129268

assignee: r.david.murray
stage: needs patch
2011-02-24 07:03:32mattcreate