Skip to content

Conversation

@esafak
Copy link
Contributor

@esafak esafak commented Aug 6, 2025

  • Safely access tcl_lib and tk_lib attributes on the interpreter.
  • This prevents AttributeError if these attributes are not present.
  • Applied to nushell, bash, fish, and via_template activation scripts.

Fixes #2944

  • 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

* Safely access tcl_lib and tk_lib attributes on the interpreter.
* This prevents AttributeError if these attributes are not present.
* Applied to nushell, bash, fish, and via_template activation scripts.

Fixes pypa#2944

Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
data.update({
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", ""),
Copy link
Contributor

Choose a reason for hiding this comment

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

How come these can be not present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, I asked the reporter for the logs.

Choose a reason for hiding this comment

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

I also don't understand why, but here is an example of a failing build: https://github.com/douwevandermeij/test-virtualenv/actions/runs/16797823289/job/47572059324

Choose a reason for hiding this comment

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

Looks like a Poetry problem

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a Poetry problem

Open an issue there please 🤔 and link it to this.

Copy link

Choose a reason for hiding this comment

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

This does not look like a poetry problem, PythonInfo is constructed and used only by virtualenv code, it is hard for me to guess how this would be anything but a virtualenv problem.

I expect you have some path that fails to populate the new fields. Probably the stuff that gets it from cache.

@gaborbernat gaborbernat marked this pull request as draft August 6, 2025 20:49
esafak and others added 3 commits August 6, 2025 17:54
Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
@gaborbernat gaborbernat marked this pull request as ready for review August 14, 2025 15:50
@gaborbernat gaborbernat merged commit dad9369 into pypa:main Aug 14, 2025
42 checks passed
@esafak esafak deleted the fix/2944-attribute-error branch August 14, 2025 15:54
gaborbernat pushed a commit to gaborbernat/virtualenv that referenced this pull request Oct 10, 2025
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

AttributeError in version 20.33.1: 'PythonInfo' object has no attribute 'tcl_lib'

4 participants