Skip to content
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

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

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.
@brettcannon brettcannon added the 🤖 automerge PR will be merged once it's been approved and all CI passed label Feb 8, 2022
@miss-islington
Copy link
Contributor

miss-islington commented Feb 8, 2022

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

@miss-islington
Copy link
Contributor

miss-islington commented Feb 8, 2022

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

1 similar comment
@miss-islington
Copy link
Contributor

miss-islington commented Feb 8, 2022

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

miss-islington commented Feb 8, 2022

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

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

miss-islington commented Feb 8, 2022

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

@miss-islington
Copy link
Contributor

miss-islington commented Feb 8, 2022

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 <notarealdeveloper@gmail.com>
@bedevere-bot
Copy link

bedevere-bot commented Feb 8, 2022

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 <notarealdeveloper@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.9 🤖 automerge PR will be merged once it's been approved and all CI passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants