They return -1 and set errno instead of returning the error number, so
OSError was raised with a meaningless error code.
(cherry picked from commit
08a0d10709f04cf03260e5e852381cecb1c531e1)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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)