From a72b33964b0ff7b0fb6114c48fbda413871e0658 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 25 Jun 2022 02:37:06 -0500 Subject: [PATCH] Require python 3.7+ We've specified this requirement for a while; enforce it before the release. --- lib/bup/cmd/save.py | 11 ++++------- lib/bup/compat.py | 7 +------ lib/cmd/bup.c | 8 ++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/bup/cmd/save.py b/lib/bup/cmd/save.py index 88f74d7..78fc79d 100644 --- a/lib/bup/cmd/save.py +++ b/lib/bup/cmd/save.py @@ -5,7 +5,7 @@ from errno import ENOENT from io import BytesIO import math, os, stat, sys, time -from bup import compat, hashsplit, git, options, index, client, metadata +from bup import hashsplit, git, options, index, client, metadata from bup import hlinkdb from bup.compat import argv_bytes, environ, nullcontext from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE, GIT_MODE_SYMLINK @@ -463,12 +463,9 @@ def save_tree(opt, reader, hlink_db, msr, w): def commit_tree(tree, parent, date, argv, writer): - if compat.py_maj > 2: - # Strip b prefix from python 3 bytes reprs to preserve previous format - msgcmd = b'[%s]' % b', '.join([repr(argv_bytes(x))[1:].encode('ascii') - for x in argv]) - else: - msgcmd = repr(argv) + # Strip b prefix from python 3 bytes reprs to preserve previous format + msgcmd = b'[%s]' % b', '.join([repr(argv_bytes(x))[1:].encode('ascii') + for x in argv]) msg = b'bup save\n\nGenerated by command:\n%s\n' % msgcmd userline = (b'%s <%s@%s>' % (userfullname(), username(), hostname())) return writer.new_commit(tree, parent, userline, date, None, diff --git a/lib/bup/compat.py b/lib/bup/compat.py index 96a228b..8dc1a51 100644 --- a/lib/bup/compat.py +++ b/lib/bup/compat.py @@ -1,15 +1,10 @@ -import os, sys - -py_maj = sys.version_info.major -assert py_maj >= 3 - # pylint: disable=unused-import from contextlib import ExitStack, nullcontext from os import environb as environ from os import fsdecode, fsencode from shlex import quote - +import os, sys def hexstr(b): """Return hex string (not bytes as with hexlify) representation of b.""" diff --git a/lib/cmd/bup.c b/lib/cmd/bup.c index 0d002a9..e61f106 100644 --- a/lib/cmd/bup.c +++ b/lib/cmd/bup.c @@ -7,6 +7,14 @@ // http://docs.python.org/3/c-api/intro.html#include-files #include +#if PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7) +#define BUP_STR(x) #x +#define BUP_XSTR(x) BUP_STR(x) +#pragma message "Python versions older than 3.7 are not supported; detected X.Y " \ + BUP_XSTR(PY_MAJOR_VERSION) "." BUP_XSTR(PY_MINOR_VERSION) +#error "Halting" +#endif + #include #include #include -- 2.39.2