They return -1 and set errno instead of returning the error number, so
OSError was raised with a meaningless error code.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
--- /dev/null
+Fix :func:`os.posix_fadvise` and :func:`os.posix_fallocate` on DragonFly BSD:
+they raised :exc:`OSError` with a meaningless error code,
+because these functions return -1 and set ``errno`` there.
Py_BEGIN_ALLOW_THREADS
result = posix_fallocate(fd, offset, length);
Py_END_ALLOW_THREADS
+ // DragonFly BSD returns -1 and sets errno.
+ if (result == -1) {
+ result = errno;
+ }
} while (result == EINTR && !(async_err = PyErr_CheckSignals()));
if (result == 0)
Py_BEGIN_ALLOW_THREADS
result = posix_fadvise(fd, offset, length, advice);
Py_END_ALLOW_THREADS
+ // DragonFly BSD returns -1 and sets errno.
+ if (result == -1) {
+ result = errno;
+ }
} while (result == EINTR && !(async_err = PyErr_CheckSignals()));
if (result == 0)