Skip to content

fix: Correctly unpack _get_tcl_tk_libs() response in PythonInfo #2940

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
merged 5 commits into from
Aug 5, 2025

Conversation

esafak
Copy link
Contributor

@esafak esafak commented Aug 5, 2025

  • Correctly unpacks the tuple returned by _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.
  • Updates activation scripts to better check TCL_LIBRARY and TK_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

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

esafak and others added 5 commits August 4, 2025 21:14
* 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]>
@gaborbernat gaborbernat enabled auto-merge August 5, 2025 02:12
@gaborbernat gaborbernat merged commit f528c19 into pypa:main Aug 5, 2025
42 checks passed
@esafak esafak deleted the fix/2930-tcl-library-bug branch August 5, 2025 02:18
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.

TypeError in virtualenv 20.33.0: expected string or bytes-like object, got 'list'
2 participants