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>
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
else: # Python 2
from pipes import quote
+ from os import environ
range = xrange
str_type = basestring