[Python-checkins] cpython (2.7): #11306: Treat EROFS like EACCES when making a 'file is read-only' decision

r.david.murray python-checkins at python.org
Wed Mar 2 16:20:51 CET 2011


http://hg.python.org/cpython/rev/e6dbba882b98
changeset:   68077:e6dbba882b98
branch:      2.7
parent:      68068:41c92cafef61
user:        R David Murray <rdmurray at bitdance.com>
date:        Wed Mar 02 09:39:48 2011 -0500
summary:
  #11306: Treat EROFS like EACCES when making a 'file is read-only' decision

files:
  Lib/mailbox.py
  Misc/NEWS

diff --git a/Lib/mailbox.py b/Lib/mailbox.py
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -554,7 +554,7 @@
                     f = open(self._path, 'wb+')
                 else:
                     raise NoSuchMailboxError(self._path)
-            elif e.errno == errno.EACCES:
+            elif e.errno in (errno.EACCES, errno.EROFS):
                 f = open(self._path, 'rb')
             else:
                 raise
@@ -1915,7 +1915,7 @@
                 pre_lock = _create_temporary(f.name + '.lock')
                 pre_lock.close()
             except IOError, e:
-                if e.errno == errno.EACCES:
+                if e.errno in (errno.EACCES, errno.EROFS):
                     return  # Without write access, just skip dotlocking.
                 else:
                     raise
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,10 @@
 Library
 -------
 
+- Issue #11306: mailbox in certain cases adapts to an inability to open
+  certain files in read-write mode.  Previously it detected this by
+  checking for EACCES, now it also checks for EROFS.
+
 - Issue #4681: Allow mmap() to work on file sizes and offsets larger than
   4GB, even on 32-bit builds.  Initial patch by Ross Lagerwall, adapted for
   32-bit Windows.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list