]> arthur.barton.de Git - bup.git/commitdiff
Require LC_CTYPE to be iso-8859-1 for Python 3
authorRob Browning <rlb@defaultvalue.org>
Sun, 3 Nov 2019 21:10:41 +0000 (15:10 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sun, 15 Dec 2019 20:57:33 +0000 (14:57 -0600)
Add a guard to compat (for now) that will crash if the LC_CYTPE isn't
ISO-8859-1 (aka Latin-1) when running under python3.  We definitely
need this for handling argv safely (with at least python 3.7), and
since we're planning to require this arrangement anyway, let's start
now.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/compat.py

index 47d0fa06cde5feebbd57e7f3b2f0acc726e00059..3707ceb5966407f7680d32bb8580a7ab911b5823 100644 (file)
@@ -12,6 +12,18 @@ py3 = py_maj >= 3
 
 if py3:
 
+    from os import environb as environ
+
+    lc_ctype = environ.get(b'LC_CTYPE')
+    if lc_ctype and lc_ctype.lower() != b'iso-8859-1':
+        # Because of argv, options.py, pwd, grp, and any number of other issues
+        print('error: bup currently only works with ISO-8859-1, not LC_CTYPE=%s'
+              % lc_ctype.decode(),
+              file=sys.stderr)
+        print('error: this should already have been arranged, so indicates a bug',
+              file=sys.stderr)
+        sys.exit(2)
+
     from os import fsencode
     from shlex import quote
     range = range
@@ -52,6 +64,7 @@ if py3:
 else:  # Python 2
 
     from pipes import quote
+    from os import environ
     range = xrange
     str_type = basestring