]> granicus.if.org Git - python/commitdiff
Merged revisions 88730 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Thu, 3 Mar 2011 18:12:34 +0000 (18:12 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Thu, 3 Mar 2011 18:12:34 +0000 (18:12 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88730 | r.david.murray | 2011-03-03 13:03:36 -0500 (Thu, 03 Mar 2011) | 2 lines

  #11306: Treat EROFS like EACCES when making a 'file is read-only' decision
........

Lib/mailbox.py
Misc/NEWS

index 2a0d321c94e766b91ffee8a25c08bb72f55c837f..ace17092b80d1647512ba60717b4d6c1e703391f 100644 (file)
@@ -578,7 +578,7 @@ class _singlefileMailbox(Mailbox):
                     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
@@ -2002,7 +2002,7 @@ def _lock_file(f, dotlock=True):
             try:
                 fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
             except IOError as e:
-                if e.errno in (errno.EAGAIN, errno.EACCES):
+                if e.errno in (errno.EAGAIN, errno.EACCES, errno.EROFS):
                     raise ExternalClashError('lockf: lock unavailable: %s' %
                                              f.name)
                 else:
@@ -2012,7 +2012,7 @@ def _lock_file(f, dotlock=True):
                 pre_lock = _create_temporary(f.name + '.lock')
                 pre_lock.close()
             except IOError as e:
-                if e.errno == errno.EACCES:
+                if e.errno in (errno.EACCES, errno.EROFS):
                     return  # Without write access, just skip dotlocking.
                 else:
                     raise
index d5512f26c0c8ad0edae39a718a71027783093888..1e2a14f438eb9bd1ef36ba4c936584d45d087d93 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -28,6 +28,10 @@ Core and Builtins
 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 #11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
   on accept(), send() and recv().