10000 gh-81793: Always call linkat() from os.link(), if available by serhiy-storchaka · Pull Request #132517 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-81793: Always call linkat() from os.link(), if available #132517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix OpenIndiana.
  • Loading branch information
serhiy-storchaka committed Apr 14, 2025
commit 5881b2a0eb6ba177468b750bf8b2026c89743d36
5 changes: 3 additions & 2 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,9 @@ def test_link_follow_symlinks(self):
link = orig + 'link'
posix.link(symlink, link)
self.addCleanup(os_helper.unlink, link)
default_follow = sys.platform.startswith(('darwin', 'freebsd', 'netbsd', 'openbsd', 'dragonfly'))
default_no_follow = sys.platform.startswith(('win32', 'linux', 'sunos5'))
default_follow = sys.platform.startswith(
('darwin', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'sunos5'))
default_no_follow = sys.platform.startswith(('win32', 'linux'))
if os.link in os.supports_follow_symlinks or default_follow:
self.assertEqual(posix.lstat(link), posix.lstat(orig))
elif default_no_follow:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Fix :func:`os.link` on platforms (like Linux and OpenIndiana) where the
system :c:func:`!link` function does not follow symlinks. On Linux and
OpenIndiana, it now follows symlinks by default and if
Fix :func:`os.link` on platforms (like Linux) where the
system :c:func:`!link` function does not follow symlinks. On Linux,
it now follows symlinks by default and if
``follow_symlinks=True`` is specified. On Windows, it now raises error if
``follow_symlinks=True`` is passed. On macOS, it now raises error if
``follow_symlinks=False`` is passed and the system :c:func:`!linkat`
Expand Down
4 changes: 2 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4364,12 +4364,12 @@ os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd,
}
/* See issue 41355: link() on Linux works like linkat without AT_SYMLINK_FOLLOW,
but on Mac it works like linkat *with* AT_SYMLINK_FOLLOW. */
#if defined(MS_WINDOWS) || defined(__linux__) || (defined(__sun) && defined(__SVR4))
#if defined(MS_WINDOWS) || defined(__linux__)
if (follow_symlinks == 1) {
argument_unavailable_error("link", "follow_symlinks=True");
return NULL;
}
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || (defined(__sun) && defined(__SVR4))
if (follow_symlinks == 0) {
argument_unavailable_error("link", "follow_symlinks=False");
return NULL;
Expand Down
0