◐ Shell
clean mode source ↗

gh-81793: Always call linkat() from os.link(), if available by serhiy-storchaka · Pull Request #132517 · python/cpython

This fixes os.link() on platforms (like Linux and OpenIndiana) where the
system link() function does not follow symlinks.

* On Linux and OpenIndiana, 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 linkat() function is not available at runtime.
* On other platforms, it now raises error if follow_symlinks is passed
  with a value that does not match the system link() function behavior
  if if the behavior is not known.

Co-authored-by: Joachim Henke <37883863+jo-he@users.noreply.github.com>
Co-authored-by: Thomas Kluyver <takowl@gmail.com>

StanFromIreland

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

serhiy-storchaka

This was referenced

May 4, 2025

diegorusso added a commit to diegorusso/cpython that referenced this pull request

May 4, 2025

Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request

Jul 12, 2025
…thonGH-132517)

This fixes os.link() on platforms (like Linux and OpenIndiana) where the
system 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 linkat() function is not available at runtime.
* On other platforms, it now raises error if follow_symlinks is passed
  with a value that does not match the system link() function behavior
  if if the behavior is not known.

Co-authored-by: Joachim Henke <37883863+jo-he@users.noreply.github.com>
Co-authored-by: Thomas Kluyver <takowl@gmail.com>