Skip to content

gh-154726: Fix shutil.copyfile() for symlinks to special files with follow_symlinks=False#154728

Open
lkk7 wants to merge 2 commits into
python:mainfrom
lkk7:fix-copyfile-device-symlink
Open

gh-154726: Fix shutil.copyfile() for symlinks to special files with follow_symlinks=False#154728
lkk7 wants to merge 2 commits into
python:mainfrom
lkk7:fix-copyfile-device-symlink

Conversation

@lkk7

@lkk7 lkk7 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #154726.

  • Avoid checking a source symlink's target when follow_symlinks=False
  • Add a regression test using a symlink to /dev/null.

@aisk

aisk commented Jul 26, 2026

Copy link
Copy Markdown
Member

fifo / socket have the same problem, and I think they are already fixed by this PR. We should update the PR's title to mention this, like using 'special file' in the news entry.

And maybe we can update the tests to test socket and fifo to ensure this and prevent future regressions. But it's up to you.

@lkk7 lkk7 changed the title gh-154726: Fix shutil.copyfile() for device symlinks with follow_symlinks=False gh-154726: Fix shutil.copyfile() for symlinks to special files with follow_symlinks=False Jul 27, 2026
@lkk7

lkk7 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Hi @aisk, done.

I just noticed that one test is not grouped with the others, but maybe it's too cosmetic to run the whole CI again for that. If any other change is needed, then I'll push that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shutil.copyfile() rejects device symlinks with follow_symlinks=False

2 participants