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

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

Merged

Conversation

davidfstr
Copy link
Contributor

@davidfstr davidfstr commented May 11, 2022

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

@JelleZijlstra JelleZijlstra May 11, 2022

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

@vsajip vsajip May 11, 2022

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

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

@bedevere-bot bedevere-bot commented May 11, 2022

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

@davidfstr davidfstr commented May 12, 2022

I have made the requested changes; please review again

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 12, 2022

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
@EwoutH
Copy link

@EwoutH EwoutH commented May 18, 2022

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

Lib/venv/__init__.py Outdated Show resolved Hide resolved
Thanks to JelleZijlstra for the feedback!

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@davidfstr
Copy link
Contributor Author

@davidfstr davidfstr commented May 18, 2022

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

Lib/test/test_venv.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented May 18, 2022

@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

@davidfstr davidfstr commented May 18, 2022

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 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 needs backport to 3.11 stdlib labels May 18, 2022
@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 18, 2022

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

@JelleZijlstra JelleZijlstra commented May 18, 2022

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

@vsajip
Copy link
Member

@vsajip vsajip commented May 18, 2022

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

@davidfstr
Copy link
Contributor Author

@davidfstr davidfstr commented May 19, 2022

NEWS item has now been added.

…erMZ.rst

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood AlexWaygood requested a review from JelleZijlstra May 19, 2022
@JelleZijlstra JelleZijlstra merged commit 30deeac into python:main May 19, 2022
13 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 19, 2022

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

@bedevere-bot bedevere-bot commented May 19, 2022

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

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 19, 2022
… for env_dir (pythonGH-92676)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 30deeac64925effe46cb5f1cd091ccb4c850ce83)

Co-authored-by: David Foster <david@dafoster.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib type-bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants