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. 


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1882780 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/backup/hot-backup.py.in b/tools/backup/hot-backup.py.in
index a7ec37f..27f9a9a 100755
--- a/tools/backup/hot-backup.py.in
+++ b/tools/backup/hot-backup.py.in
@@ -36,6 +36,7 @@
 ######################################################################
 
 import sys, os, getopt, stat, re, time, shutil, subprocess
+import locale
 import functools
 
 ######################################################################
@@ -204,10 +205,18 @@
   """Examine the repository REPO_DIR using the svnlook binary
   specified by SVNLOOK, and return the youngest revision."""
 
-  p = subprocess.Popen([svnlook, 'youngest', '--', repo_dir],
-                       stdin=subprocess.PIPE,
-                       stdout=subprocess.PIPE,
-                       stderr=subprocess.PIPE)
+  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 @@
     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