Skip to content

bpo-46678: Fix Invalid cross device link in Lib/test/support/import_helper.py #31204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

notarealdeveloper
Copy link
Contributor

@notarealdeveloper notarealdeveloper commented Feb 7, 2022

In Lib/test/support/import_helper.py, the function make_legacy_pyc makes a call to os.rename which can fail when the source and target live on different devices. This happens (for example) when PYTHONPYCACHEPREFIX is set to a directory anywhere on disk, while a ramdisk is mounted on /tmp (the latter of which is the default on various Linux distros). Replacing os.rename with shutil.move fixes this.

https://bugs.python.org/issue46678

Automerge-Triggered-By: GH:brettcannon

os.rename fails if the source and target live on different
devices. This can occur in Lib/test/support/import_helper.py
(for example) if /tmp is mounted as a ramdisk, or more
generally if PYTHONPYCACHEPREFIX is set to a directory
on a different drive from where temporary files are stored.
@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: 4 of 6 required status checks are expected..

@brettcannon brettcannon added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Feb 8, 2022
@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: 4 of 6 required status checks are expected..

1 similar comment
@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: 4 of 6 required status checks are expected..

@brettcannon brettcannon self-assigned this Feb 8, 2022
@miss-islington
Copy link
Contributor

@notarealdeveloper: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit da576e0 into python:main Feb 8, 2022
@miss-islington
Copy link
Contributor

Thanks @notarealdeveloper for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @notarealdeveloper, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker da576e08296490e94924421af71001bcfbccb317 3.9

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 8, 2022
…elper.py (pythonGH-31204)

In [Lib/test/support/import_helper.py](https://github.com/python/cpython/blob/master/Lib/test/support/import_helper.py), the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this.

Automerge-Triggered-By: GH:brettcannon
(cherry picked from commit da576e0)

Co-authored-by: Jason Wilkes <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Feb 8, 2022
@bedevere-bot
Copy link

GH-31207 is a backport of this pull request to the 3.10 branch.

brettcannon pushed a commit that referenced this pull request Feb 8, 2022
…elper.py (GH-31204) (GH-31207)

In `Lib/test/support/import_helper.py`, the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this.

Automerge-Triggered-By: GH:brettcannon
(cherry picked from commit da576e0)

Co-authored-by: Jason Wilkes <[email protected]>
@ZeroIntensity ZeroIntensity removed the needs backport to 3.9 only security fixes label Feb 17, 2025
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.

6 participants