From: Rob Browning Date: Sun, 2 Sep 2018 17:29:01 +0000 (-0500) Subject: Refuse to run by default if python version is not 2 X-Git-Tag: 0.30~56 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=d30215975cb04ed75f027006defa5b35c3f6a3ac Refuse to run by default if python version is not 2 Exit with an error if the python major version isn't 2, since we're working on support for py3, and we'll probably reach a point before we're finished where bup doesn't immediately crash with py3, but might well do very bad things to the repository. Allow overriding the check by setting BUP_ALLOW_UNEXPECTED_PYTHON_VERSION=true so people can still test py3 if they like. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/main.py b/main.py index 19675cd..c0679e3 100755 --- a/main.py +++ b/main.py @@ -5,9 +5,15 @@ exec "$bup_python" "$0" ${1+"$@"} """ # end of bup preamble -from __future__ import absolute_import +from __future__ import absolute_import, print_function import errno, re, sys, os, subprocess, signal, getopt +if sys.version_info[0] != 2 \ + and not os.environ.get('BUP_ALLOW_UNEXPECTED_PYTHON_VERSION') == 'true': + print('error: bup may crash with python versions other than 2, or eat your data', + file=sys.stderr) + sys.exit(2) + from subprocess import PIPE from sys import stderr, stdout import select