Skip to content

Make create_link error on cross-device links - #1338

Merged
mrbean-bremen merged 2 commits into
pytest-dev:mainfrom
shannonmcin:cross-device-hard-link
Sep 9, 2026
Merged

mrbean-bremen merged 2 commits into
pytest-dev:mainfrom
shannonmcin:cross-device-hard-link

Conversation

@shannonmcin

@shannonmcin shannonmcin commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Describe the changes

See #1337

The current hardlink implementation in pyfakefs does not raise an error on a cross-device link, while os.file does. This PR raises an OSError if the source and destination files have different device IDs.

Unit test pass:

$ python -m pyfakefs.tests.all_tests &> test_out.log
$ echo $?
0

Tasks

  • Unit tests added that reproduce the issue or prove feature is working
  • Fix or feature added
  • Entry to release notes added
  • Pre-commit CI shows no errors
  • Unit tests passing
  • For documentation changes: The Read the Docs preview builds and looks as expected

@shannonmcin
shannonmcin force-pushed the cross-device-hard-link branch from 60080c5 to 603bd03 Compare September 8, 2026 21:56
@shannonmcin
shannonmcin marked this pull request as ready for review September 8, 2026 21:57

@mrbean-bremen mrbean-bremen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - looks good apart from the test that has to be adapted.

Comment thread pyfakefs/tests/fake_filesystem_test.py Outdated
Comment thread pyfakefs/tests/fake_filesystem_test.py
@mrbean-bremen
mrbean-bremen merged commit 8e7ab9e into pytest-dev:main Sep 9, 2026
104 checks passed
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.

2 participants