Avoid UnicodeDecodeError when svnlook returns error message.
* tools/backup/hot-backup.py.in
(): Import locale moule for locale.getpreferredencoding.
(get_youngest_revision): Use str for I/O in subprocess.Popen on Python 3.
######################################################################
import sys, os, getopt, stat, re, time, shutil, subprocess
+import locale
import functools
######################################################################
@@ -204,10 +205,18 @@ def get_youngest_revision():
"""Examine the repository REPO_DIR using the svnlook binary
specified by SVNLOOK, and return the youngest revision."""
+ if b'' == '':
p = subprocess.Popen([svnlook, 'youngest', '--', repo_dir],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ else:
+ p = subprocess.Popen([svnlook, 'youngest', '--', repo_dir],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ errors='backslashreplace', # foolproof
+ encoding=locale.getpreferredencoding())
infile, outfile, errfile = p.stdin, p.stdout, p.stderr
stdout_lines = outfile.readlines()
@@ -220,7 +229,7 @@ def get_youngest_revision():
raise Exception("Unable to find the youngest revision for repository '%s'"
": %s" % (repo_dir, stderr_lines[0].rstrip()))
- return stdout_lines[0].strip().decode()
+ return stdout_lines[0].strip()
######################################################################
# Main
