fix: Correctly unpack _get_tcl_tk_libs() response in PythonInfo#2940
Merged
gaborbernat merged 5 commits intopypa:mainfrom Aug 5, 2025
Merged
fix: Correctly unpack _get_tcl_tk_libs() response in PythonInfo#2940gaborbernat merged 5 commits intopypa:mainfrom
gaborbernat merged 5 commits intopypa:mainfrom
Conversation
* Fixes a TypeError when creating a virtual environment after deactivation. * Correctly handles the TCL_LIBRARY environment variable. * Updates activation scripts to correctly check TCL_LIBRARY and TK_LIBRARY. * Correctly unpacks the tuple returned by _get_tcl_tk_libs. Fixes pypa#2930 Signed-off-by: Emre Şafak <[email protected]>
Signed-off-by: Emre Şafak <[email protected]>
Signed-off-by: Emre Şafak <[email protected]>
gaborbernat
approved these changes
Aug 5, 2025
4 tasks
zanieb
pushed a commit
to astral-sh/uv
that referenced
this pull request
Sep 5, 2025
## Summary This refreshes the venv activation scripts from upstream `virtualenv` project. This was largely triggered by a problem in the activate.nu script (for nushell): - #14888 - #14914 - #14917 I was careful to respect the git history going back to #3376 (the last time this was done). Actually I looked at the complete history from back when this `uv-virtualenv` crate was named after a Pokémon (⁉️ ), but I found nothing (about activation scripts) from back then that hasn't been overwritten since. ### Some post-processing was involved - Retained license info at top of scripts - Retained template vars (eg `{{ BIN_PATH }}`) to assure current support toward relocatable venv - Retained deviation from upstream in #5640. This seems to be the only deviation that isn't in sync with upstream. ### Notable changes from upstream - (omitted due to undesirable complexity) pypa/virtualenv#2928 and its follow-up pypa/virtualenv#2940 - pypa/virtualenv#2910 (what prompted #14917 from #14888) ## Test Plan There was a request in #14917 to add unit tests to detect breakage or errors. I have added a CI job that runs the nushell activation script. But I think it is better to have the CI test all/most supported shells. See also #15294 I have tested this locally using - [x] nushell (v0.106.1) - [x] cmd.exe (Microsoft Windows [Version 10.0.26100.4946]) - [x] bash in WSL (GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)) - [x] pwsh (PSVersion 5.1.26100.4768)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_get_tcl_tk_libs, fixing a TypeError when creating a virtual environment after deactivation. The code looks correct at first glance, but due to Python's idiosyncratic tuple unpacking, both values were assigned to the first argument and none to the latter, causing the bug. This would not have happened in a statically typed language. Once we drop 3.8 support I'd like to liberally annotate the code base using the native type syntax and validate types too.TCL_LIBRARYandTK_LIBRARY. This also reminded me shell scripts are error prone and to be minimized.To verify the fix I created scripts for every shell, and saw that 20.33 does indeed fail in bash, but not the others, and none fail after the fix.
Fixes #2930
tox -e fix)docs/changelogfolder