Skip to content

gh-92675: venv: Fix ensure_directories() to again accept a Path for env_dir #92676

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

Merged

Conversation

davidfstr
Copy link
Contributor

Fixes: #92675

@@ -116,7 +116,7 @@ def create_if_needed(d):
elif os.path.islink(d) or os.path.isfile(d):
raise ValueError('Unable to create directory %r' % d)

if os.pathsep in env_dir:
if isinstance(env_dir, str) and os.pathsep in env_dir:
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the intent here is to enforce that env_dir is only a single path segment. Should we preserve that behavior for path-likes too? For example, we could call env_dir = os.fspath(env_dir) first.

I'm not sure why we need to check for this at all though. What is the reason we have this check?

Copy link
Member

Choose a reason for hiding this comment

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

It's checking for os.pathsep, not os.sep: it was a fix for bpo-43218. I agree, we should retain the behaviour for path-likes too - otherwise the problem originally solved for will come back.

Copy link
Member

@vsajip vsajip left a comment

Choose a reason for hiding this comment

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

Please see comments about a possible change in behaviour, and please add tests (including a failure test for the bpo-43218 issue when a dir containing os.pathsep is passed as a Path).

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@davidfstr
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@vsajip: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from vsajip May 12, 2022 13:25
@EwoutH
Copy link

EwoutH commented May 18, 2022

Thanks for the effort fixing this issue! Any update on its status?

Thanks to JelleZijlstra for the feedback!

Co-authored-by: Jelle Zijlstra <[email protected]>
@davidfstr
Copy link
Contributor Author

@JelleZijlstra thanks for the feedback! Did apply your suggestion.

Co-authored-by: Alex Waygood <[email protected]>
@AlexWaygood
Copy link
Member

@davidfstr you can fix the other CI failure by adding a NEWS entry using https://blurb-it.herokuapp.com. I think it probably does need a NEWS entry, since this is a bugfix :)

@davidfstr
Copy link
Contributor Author

adding a NEWS entry using https://blurb-it.herokuapp.com/. I think it probably does need a NEWS entry, since this is a bugfix :)

I'll plan to look at this tomorrow.

I was previously thinking that no NEWS entry would be required since I'm fixing a bug that only affects a pre-release version of Python (i.e. Python 3.11 beta 1).

@AlexWaygood
Copy link
Member

AlexWaygood commented May 18, 2022

I was previously thinking that no NEWS entry would be required since I'm fixing a bug that only affects a pre-release version of Python (i.e. Python 3.11 beta 1).

The bug is nonetheless present in a released version of Python, even if it's not a production-ready release :) The changelog needs to reflect changes that took place in between Beta 1 and Beta 2, and this was a user-visible bug in Beta 1.

@AlexWaygood AlexWaygood added type-bug An unexpected behavior, bug, or error needs backport to 3.11 only security fixes stdlib Python modules in the Lib dir labels May 18, 2022
@JelleZijlstra
Copy link
Member

Thanks! Once the news entry is added, I think this should be good to go. Hopefully @vsajip will be able to give another review; if not I can merge the fix, since his previous concerns have been addressed and it seems important that the bug fix makes it into beta 2.

@JelleZijlstra
Copy link
Member

(Beta 2 is scheduled for May 30, less than 2 weeks away: PEP-664.)

@vsajip
Copy link
Member

vsajip commented May 18, 2022

Yes, it's fine by me to merge once the NEWS item is added.

@davidfstr
Copy link
Contributor Author

NEWS item has now been added.

@AlexWaygood AlexWaygood requested a review from JelleZijlstra May 19, 2022 14:43
@miss-islington
Copy link
Contributor

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

@bedevere-bot
Copy link

GH-92961 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label May 19, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 19, 2022
… for env_dir (pythonGH-92676)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
(cherry picked from commit 30deeac)

Co-authored-by: David Foster <[email protected]>
@davidfstr
Copy link
Contributor Author

Thanks all for providing a good first† experience in contributing to the CPython repository!

† At least my first experience since most of CPython infrastructure did move to GitHub. I believe I contributed the first version of asyncio's debug mode a few years ago.

miss-islington added a commit that referenced this pull request May 19, 2022
…nv_dir (GH-92676)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
(cherry picked from commit 30deeac)

Co-authored-by: David Foster <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

venv.EnvBuilder.ensure_directories() no longer accepts Path for env_dir parameter
7 participants