Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 752b950

Browse files
committed
Merged revisions 88730 via svnmerge from
svn+ssh://[email protected]/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 ........
1 parent 00a4286 commit 752b950

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/mailbox.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def __init__(self, path, factory=None, create=True):
578578
f = open(self._path, 'wb+')
579579
else:
580580
raise NoSuchMailboxError(self._path)
581-
elif e.errno == errno.EACCES:
581+
elif e.errno in (errno.EACCES, errno.EROFS):
582582
f = open(self._path, 'rb')
583583
else:
584584
raise
@@ -2002,7 +2002,7 @@ def _lock_file(f, dotlock=True):
20022002
try:
20032003
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
20042004
except IOError as e:
2005-
if e.errno in (errno.EAGAIN, errno.EACCES):
2005+
if e.errno in (errno.EAGAIN, errno.EACCES, errno.EROFS):
20062006
raise ExternalClashError('lockf: lock unavailable: %s' %
20072007
f.name)
20082008
else:
@@ -2012,7 +2012,7 @@ def _lock_file(f, dotlock=True):
20122012
pre_lock = _create_temporary(f.name + '.lock')
20132013
pre_lock.close()
20142014
except IOError as e:
2015-
if e.errno == errno.EACCES:
2015+
if e.errno in (errno.EACCES, errno.EROFS):
20162016
return # Without write access, just skip dotlocking.
20172017
else:
20182018
raise

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Core and Builtins
2828
Library
2929
-------
3030

31+
- Issue #11306: mailbox in certain cases adapts to an inability to open
32+
certain files in read-write mode. Previously it detected this by
33+
checking for EACCES, now it also checks for EROFS.
34+
3135
- Issue #11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
3236
on accept(), send() and recv().
3337

0 commit comments

Comments
 (0)