]> arthur.barton.de Git - bup.git/commitdiff
compat: add range and use it in the vfs
authorRob Browning <rlb@defaultvalue.org>
Sat, 31 Mar 2018 21:42:53 +0000 (16:42 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 31 Mar 2018 22:14:33 +0000 (17:14 -0500)
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 <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/compat.py
lib/bup/vfs.py

index 8a142822f4f84d7f00441d7224864b5f478a1958..895a84a3da86ac65c63ba184e94c341cdef15d14 100644 (file)
@@ -11,6 +11,7 @@ py3 = py_maj >= 3
 
 if py3:
 
 
 if py3:
 
+    range = range
     str_type = str
 
     def add_ex_tb(ex):
     str_type = str
 
     def add_ex_tb(ex):
@@ -26,6 +27,7 @@ if py3:
 
 else:  # Python 2
 
 
 else:  # Python 2
 
+    range = xrange
     str_type = basestring
 
     def add_ex_tb(ex):
     str_type = basestring
 
     def add_ex_tb(ex):
index f231f4d790ddd48913dd1c2ad8025a33aa28b4db..14293dc202e8fb50172d8e1f03a9e29ecabcfba8 100644 (file)
@@ -54,6 +54,7 @@ from time import localtime, strftime
 import exceptions, re, sys
 
 from bup import client, git, metadata
 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
 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'
         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):
                 yield fmt % (name, i)
 
 def parse_rev(f):