python / python/cpython

Wrong `follow_symlinks` default fallback implementation

Open
#119,885 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

By https://github.com/python/cpython/blob/96b392d/Modules/posixmodule.c#L4274, if follow_symlinks = True, Python will choose to call syscall link rather than linkat. However, the behavior of link will have AT_SYMLINK_FOLLOW unset, which leads an opposite behavior.

import os
os.link('link', 'another-file')
wrong implementation of follow_symlinks
CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

### Tasks
Linked PRs
  • gh-119886

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the fallback implementation in Modules/posixmodule.c around line 4274 and reproduce the os.link example on Linux to compare link and linkat behavior with follow_symlinks=True. Review linked PR gh-119886 for the work already underway; done means the fallback matches the documented follow_symlinks behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.