dov.gr...@gmail.com writes:
> So I can narrow down my patch to only catch OSError if you prefer? Or do
> you want me to narrow it down further to only errno=22?
Looks like both Linux and POSIX agree that EINVAL just indicates that
the underlying filesystem "can't do it", and Linux may also report EROFS
if the filesystem is read-only:
POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/functions/fsync.html
Linux:
EBADF fd is not a valid open file descriptor.
EIO An error occurred during synchronization.
EROFS, EINVAL
fd is bound to a special file (e.g., a pipe, FIFO, or socket)
which does not support synchronization.
So it sounds plausible to quash EINVAL (and if it exists, EROFS). One
possibliity might be something like:
if hasattr(errno, 'EROFS'):
fsync_notsup_errnos = (errno.EINVAL, errno.EROFS)
else
fsync_notsup_errnos = (errno.EINVAL,)
...
if ex.errno in fsync_notsup_errnos:
...
(Oh, and you're welcome to update your PR branch if you prefer that to
posting the changes here (in which case, I'll forward them for you).)