Jo Henke <[email protected]> added the comment:
The problem that POSIX does not define the behavior of link() regarding
symlinks (and that Unix implementations differ indeed), is independent from
Python's os.link() defaults.
Since it makes no sense to call link(), when linkat() is available, I propose
this change:
--- 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)
This fix also simplifies the code, and should be safe for back-porting.
Whether Python's defaults should be changed regarding Windows and those (mostly
obsolete) Unix platforms that do not provide linkat(), is another question.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37612>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com