diff --git a/Misc/NEWS.d/next/Library/2019-07-19-09-57-18.bpo-37612.yjjxx-.rst b/Misc/NEWS.d/next/Library/2019-07-19-09-57-18.bpo-37612.yjjxx-.rst new file mode 100644 index 00000000000000..85d2775110ac9e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-07-19-09-57-18.bpo-37612.yjjxx-.rst @@ -0,0 +1 @@ +fix os.link() on platforms (like Linux) where the system link() function does not follow symlinks \ No newline at end of file diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 777e933cab59b5..9e9a119b1418cc 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3512,15 +3512,11 @@ os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, #else Py_BEGIN_ALLOW_THREADS #ifdef HAVE_LINKAT - if ((src_dir_fd != DEFAULT_DIR_FD) || - (dst_dir_fd != DEFAULT_DIR_FD) || - (!follow_symlinks)) - result = linkat(src_dir_fd, src->narrow, - dst_dir_fd, dst->narrow, - follow_symlinks ? AT_SYMLINK_FOLLOW : 0); - else + result = linkat(src_dir_fd, src->narrow, dst_dir_fd, dst->narrow, + follow_symlinks ? AT_SYMLINK_FOLLOW : 0); +#else + result = link(src->narrow, dst->narrow); #endif /* HAVE_LINKAT */ - result = link(src->narrow, dst->narrow); Py_END_ALLOW_THREADS if (result)