Skip to content

Commit dad9369

Browse files
fix: Use getattr for tcl/tk library paths (#2945)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 916375d commit dad9369

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

docs/changelog/2944.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replaced direct references to tcl/tk library paths with getattr. By :user:`esafak`

src/virtualenv/activation/bash/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def as_name(self, template):
1515
def replacements(self, creator, dest):
1616
data = super().replacements(creator, dest)
1717
data.update({
18-
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
19-
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
18+
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", None) or "",
19+
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", None) or "",
2020
})
2121
return data
2222

src/virtualenv/activation/fish/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def templates(self):
1010
def replacements(self, creator, dest):
1111
data = super().replacements(creator, dest)
1212
data.update({
13-
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
14-
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
13+
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", None) or "",
14+
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", None) or "",
1515
})
1616
return data
1717

src/virtualenv/activation/nushell/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def replacements(self, creator, dest_folder): # noqa: ARG002
3434
"__VIRTUAL_ENV__": str(creator.dest),
3535
"__VIRTUAL_NAME__": creator.env_name,
3636
"__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
37-
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
38-
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
37+
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", None) or "",
38+
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", None) or "",
3939
}
4040

4141

src/virtualenv/activation/via_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def replacements(self, creator, dest_folder): # noqa: ARG002
4747
"__VIRTUAL_NAME__": creator.env_name,
4848
"__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
4949
"__PATH_SEP__": os.pathsep,
50-
"__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
51-
"__TK_LIBRARY__": creator.interpreter.tk_lib or "",
50+
"__TCL_LIBRARY__": getattr(creator.interpreter, "tcl_lib", None) or "",
51+
"__TK_LIBRARY__": getattr(creator.interpreter, "tk_lib", None) or "",
5252
}
5353

5454
def _generate(self, replacements, templates, to_folder, creator):

0 commit comments

Comments
 (0)