Skip to content

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

Merged
encukou merged 4 commits into
python:mainfrom
lkk7:fix-copyfile-device-symlink
Jul 31, 2026
Merged

gh-154726: Fix shutil.copyfile() for symlinks to special files with follow_symlinks=False#154728
encukou merged 4 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.

Comment thread Lib/test/test_shutil.py Outdated
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 30, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit bf7e3d2 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F154728%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 30, 2026
@encukou
encukou merged commit f5afa89 into python:main Jul 31, 2026
129 of 141 checks passed
@encukou encukou added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 31, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @lkk7 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @lkk7 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @lkk7 and @encukou, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f5afa895ae322ea89c5942b0b21094c124293dd8 3.15

@miss-islington-app

Copy link
Copy Markdown

Sorry, @lkk7 and @encukou, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f5afa895ae322ea89c5942b0b21094c124293dd8 3.15

@encukou

encukou commented Jul 31, 2026

Copy link
Copy Markdown
Member

Oh, #142693 is only in 3.16.

@encukou encukou removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants