Skip to content

Commit

Permalink
hookutils: tcl/tk: always use utf8 encoding on macOS
Browse files Browse the repository at this point in the history
When trying to determine the type of Tcl/Tk installation on
macOS by reading the `init.tcl` file, assume the UTF-8 encoding
instead if trying to query it via `locale.getpreferredencoding`
to avoid an `EncodingWarning`.
  • Loading branch information
rokm committed Nov 26, 2023
1 parent 5375359 commit 494bfad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PyInstaller/utils/hooks/tcl_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------

import locale
import os

from PyInstaller import compat
Expand Down Expand Up @@ -96,7 +95,8 @@ def _warn_if_activetcl_or_teapot_installed(tcl_root, tcltree):
mentions_teapot = False
# TCL/TK reads files using the system encoding:
# https://www.tcl.tk/doc/howto/i18n.html#system_encoding
with open(init_resource, 'r', encoding=locale.getpreferredencoding()) as init_file:
# On macOS, system encoding is UTF-8
with open(init_resource, 'r', encoding='utf8') as init_file:
for line in init_file.readlines():
line = line.strip().lower()
if line.startswith('#'):
Expand Down

0 comments on commit 494bfad

Please sign in to comment.