Skip to content

Commit

Permalink
Supply encoding parameter, suppressing EncodingWarnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 28, 2023
1 parent 0223c71 commit b33fcab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,8 @@
v2.4.0
======

Supply the encoding, fixing EncodingWarnings.

v2.3.1
======

Expand Down
8 changes: 5 additions & 3 deletions rst/linker.py
Expand Up @@ -121,9 +121,11 @@ def _get_scm_info_for(scm_version):
)
cmd = commands[scm]
try:
with open(os.devnull, 'w') as devnull:
out = subprocess.check_output(cmd, stderr=devnull)
ts = out.decode('utf-8').strip()
with open(os.devnull, 'w', encoding='utf-8') as devnull:
out = subprocess.check_output(
cmd, stderr=devnull, text=True, encoding='utf-8'
)
ts = out.strip()
return dict(timestamp=dateutil.parser.parse(ts))
except Exception:
pass
Expand Down
5 changes: 3 additions & 2 deletions test_all.py
Expand Up @@ -52,10 +52,11 @@ def test_write_links(linker_defn):
---
proj 1.0 was released
"""
""",
encoding='utf-8',
)
repl.write_links(source, dest)
res = dest.read_text()
res = dest.read_text(encoding='utf-8')
assert 'kilnhg' in res
source.remove()
dest.remove()
Expand Down

0 comments on commit b33fcab

Please sign in to comment.