mirror of https://github.com/python/cpython.git
#11306: Treat EROFS like EACCES when making a 'file is read-only' decision
This commit is contained in:
parent
acdad9a40b
commit
91221f2857
|
@ -578,7 +578,7 @@ def __init__(self, path, factory=None, create=True):
|
||||||
f = open(self._path, 'wb+')
|
f = open(self._path, 'wb+')
|
||||||
else:
|
else:
|
||||||
raise NoSuchMailboxError(self._path)
|
raise NoSuchMailboxError(self._path)
|
||||||
elif e.errno == errno.EACCES:
|
elif e.errno in (errno.EACCES, errno.EROFS):
|
||||||
f = open(self._path, 'rb')
|
f = open(self._path, 'rb')
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
@ -2002,7 +2002,7 @@ def _lock_file(f, dotlock=True):
|
||||||
try:
|
try:
|
||||||
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
except IOError as e:
|
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' %
|
raise ExternalClashError('lockf: lock unavailable: %s' %
|
||||||
f.name)
|
f.name)
|
||||||
else:
|
else:
|
||||||
|
@ -2012,7 +2012,7 @@ def _lock_file(f, dotlock=True):
|
||||||
pre_lock = _create_temporary(f.name + '.lock')
|
pre_lock = _create_temporary(f.name + '.lock')
|
||||||
pre_lock.close()
|
pre_lock.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
if e.errno == errno.EACCES:
|
if e.errno in (errno.EACCES, errno.EROFS):
|
||||||
return # Without write access, just skip dotlocking.
|
return # Without write access, just skip dotlocking.
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -52,6 +52,10 @@ Core and Builtins
|
||||||
Library
|
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
|
- Issue #11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
|
||||||
on accept(), send() and recv().
|
on accept(), send() and recv().
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue