Skip to content

Commit

Permalink
Use getpreferredencoding over getencoding to restore python 3.9 and 3…
Browse files Browse the repository at this point in the history
….10 compatibility.
  • Loading branch information
nomike committed Sep 18, 2024
1 parent 3a2743a commit c42774d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions templatehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# pylint: disable=invalid-name
config = None

with open("../config.yaml", encoding=locale.getencoding()) as file:
with open("../config.yaml", encoding=locale.getpreferredencoding()) as file:
config = yaml.load(file, Loader=yaml.SafeLoader)


Expand Down Expand Up @@ -84,7 +84,7 @@ def listdir(path):
if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')):
with open(
os.path.join(pathprefix, path, '.scmsignore'),
encoding=locale.getencoding()) as scsmignore:
encoding=locale.getpreferredencoding()) as scsmignore:
ignorelist.extend([line.strip('\n') for line in scsmignore.readlines()])
dirlist = [
os.path.basename(f)
Expand Down Expand Up @@ -117,7 +117,7 @@ def listchildren(path):
if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')):
with open(
os.path.join(pathprefix, path, '.scmsignore'),
encoding=locale.getencoding()) as scmsignore:
encoding=locale.getpreferredencoding()) as scmsignore:
ignorelist.extend([line.strip('\n') for line in scmsignore.readlines()])
dirlist = [
[os.path.basename(f), os.path.basename(f)]
Expand All @@ -127,7 +127,7 @@ def listchildren(path):
if os.path.exists(os.path.join(pathprefix, path, '.scmslinks')):
with open(
os.path.join(pathprefix, path, '.scmslinks'),
encoding=locale.getencoding()) as scmslinks:
encoding=locale.getpreferredencoding()) as scmslinks:
additional_links = json.load(scmslinks)
dirlist.extend(additional_links)
removeitems = []
Expand Down

0 comments on commit c42774d

Please sign in to comment.