From 55669f6cfc03e96cee236dc9b9cdeb1deb31cef0 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Mon, 18 Apr 2022 02:32:06 +0100 Subject: Specify encoding --- utils/bump_version.py | 10 +++++----- utils/doclinter.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/bump_version.py b/utils/bump_version.py index 1d2101c6d..aeaed864b 100755 --- a/utils/bump_version.py +++ b/utils/bump_version.py @@ -27,7 +27,7 @@ def bump_version(path, version_info, in_develop=True): if in_develop: version += '+' - with open(path, 'r+') as f: + with open(path, 'r+', encoding='utf-8') as f: body = f.read() body = re.sub(r"(?<=__version__ = ')[^']+", version, body) body = re.sub(r"(?<=__released__ = ')[^']+", release, body) @@ -88,7 +88,7 @@ class Changes: self.fetch_version() def fetch_version(self): - with open(self.path) as f: + with open(self.path, encoding='utf-8') as f: version = f.readline().strip() matched = re.search(r'^Release (.*) \((.*)\)$', version) if matched is None: @@ -105,7 +105,7 @@ class Changes: release_date = datetime.now().strftime('%b %d, %Y') heading = 'Release %s (released %s)' % (self.version, release_date) - with open(self.path, 'r+') as f: + with open(self.path, 'r+', encoding='utf-8') as f: f.readline() # skip first two lines f.readline() body = f.read() @@ -126,12 +126,12 @@ class Changes: version_info[4] or '') heading = 'Release %s (in development)' % version - with open(os.path.join(script_dir, 'CHANGES_template')) as f: + with open(os.path.join(script_dir, 'CHANGES_template'), encoding='utf-8') as f: f.readline() # skip first two lines f.readline() tmpl = f.read() - with open(self.path, 'r+') as f: + with open(self.path, 'r+', encoding='utf-8') as f: body = f.read() f.seek(0) diff --git a/utils/doclinter.py b/utils/doclinter.py index 6ef8cbe10..d67a49b05 100644 --- a/utils/doclinter.py +++ b/utils/doclinter.py @@ -12,7 +12,7 @@ LEADING_SPACES = re.compile(r'^(\s*)') def lint(path: str) -> int: - with open(path) as f: + with open(path, encoding='utf-8') as f: document = f.readlines() errors = 0 -- cgit v1.2.1