diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-11-02 08:00:10 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-11-04 11:21:25 +0100 |
| commit | e0e88ceaaae4b27913cc9d3b48bf79c681605fba (patch) | |
| tree | d5be1bca88abc57dff70b34578331cc280f6445e | |
| parent | 5a856669bf0574f612eea89e72a6b0a3d2cb80d9 (diff) | |
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
| -rw-r--r-- | scripts/manage_translations.py | 11 | ||||
| -rw-r--r-- | tests/postgres_tests/test_integration.py | 6 |
2 files changed, 10 insertions, 7 deletions
diff --git a/scripts/manage_translations.py b/scripts/manage_translations.py index bf4cb79ad1..e67bf6e74d 100644 --- a/scripts/manage_translations.py +++ b/scripts/manage_translations.py @@ -124,14 +124,17 @@ def lang_stats(resources=None, languages=None): p = run( ['msgfmt', '-vc', '-o', '/dev/null', po_path], stdout=PIPE, stderr=PIPE, - env={'LANG': 'C'} + env={'LANG': 'C'}, + encoding='utf-8', ) if p.returncode == 0: # msgfmt output stats on stderr - print("%s: %s" % (lang, p.stderr.decode().strip())) + print('%s: %s' % (lang, p.stderr.strip())) else: - print("Errors happened when checking %s translation for %s:\n%s" % ( - lang, name, p.stderr.decode())) + print( + 'Errors happened when checking %s translation for %s:\n%s' + % (lang, name, p.stderr) + ) def fetch(resources=None, languages=None): diff --git a/tests/postgres_tests/test_integration.py b/tests/postgres_tests/test_integration.py index da3ccb028d..db082a6495 100644 --- a/tests/postgres_tests/test_integration.py +++ b/tests/postgres_tests/test_integration.py @@ -16,7 +16,7 @@ class PostgresIntegrationTests(PostgreSQLSimpleTestCase): stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, cwd=os.path.dirname(__file__), - env=test_environ + env=test_environ, + encoding='utf-8', ) - stderr = '\n'.join([e.decode() for e in result.stderr.splitlines()]) - self.assertEqual(result.returncode, 0, msg=stderr) + self.assertEqual(result.returncode, 0, msg=result.stderr) |
