From 217eb3b7cc793f678e533993025d3be6747fe3e9 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 31 Mar 2018 16:42:53 -0500 Subject: [PATCH] compat: add range and use it in the vfs Define range as range for py3 and xrange for py2, so that we'll have the same semantics both places. Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/compat.py | 2 ++ lib/bup/vfs.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bup/compat.py b/lib/bup/compat.py index 8a14282..895a84a 100644 --- a/lib/bup/compat.py +++ b/lib/bup/compat.py @@ -11,6 +11,7 @@ py3 = py_maj >= 3 if py3: + range = range str_type = str def add_ex_tb(ex): @@ -26,6 +27,7 @@ if py3: else: # Python 2 + range = xrange str_type = basestring def add_ex_tb(ex): diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index f231f4d..14293dc 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -54,6 +54,7 @@ from time import localtime, strftime import exceptions, re, sys from bup import client, git, metadata +from bup.compat import range from bup.git import BUP_CHUNKED, cp, get_commit_items, parse_commit, tree_decode from bup.helpers import debug2, last from bup.metadata import Metadata @@ -576,7 +577,7 @@ def _reverse_suffix_duplicates(strs): else: ndig = len(str(ndup - 1)) fmt = '%s-' + '%0' + str(ndig) + 'd' - for i in xrange(ndup - 1, -1, -1): + for i in range(ndup - 1, -1, -1): yield fmt % (name, i) def parse_rev(f): -- 2.39.2