Skip to content

Commit e0e88ce

Browse files
jdufresnefelixxm
authored andcommitted
Refs #30116 -- Simplified stdout/stderr decoding with subprocess.run()'s encoding argument.
The encoding argument has been available since Python 3.6. https://docs.python.org/3/library/subprocess.html#subprocess.run
1 parent 5a85666 commit e0e88ce

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

scripts/manage_translations.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,17 @@ def lang_stats(resources=None, languages=None):
124124
p = run(
125125
['msgfmt', '-vc', '-o', '/dev/null', po_path],
126126
stdout=PIPE, stderr=PIPE,
127-
env={'LANG': 'C'}
127+
env={'LANG': 'C'},
128+
encoding='utf-8',
128129
)
129130
if p.returncode == 0:
130131
# msgfmt output stats on stderr
131-
print("%s: %s" % (lang, p.stderr.decode().strip()))
132+
print('%s: %s' % (lang, p.stderr.strip()))
132133
else:
133-
print("Errors happened when checking %s translation for %s:\n%s" % (
134-
lang, name, p.stderr.decode()))
134+
print(
135+
'Errors happened when checking %s translation for %s:\n%s'
136+
% (lang, name, p.stderr)
137+
)
135138

136139

137140
def fetch(resources=None, languages=None):

tests/postgres_tests/test_integration.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_check(self):
1616
stdout=subprocess.DEVNULL,
1717
stderr=subprocess.PIPE,
1818
cwd=os.path.dirname(__file__),
19-
env=test_environ
19+
env=test_environ,
20+
encoding='utf-8',
2021
)
21-
stderr = '\n'.join([e.decode() for e in result.stderr.splitlines()])
22-
self.assertEqual(result.returncode, 0, msg=stderr)
22+
self.assertEqual(result.returncode, 0, msg=result.stderr)

0 commit comments

Comments
 (0)