mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
python: Replace xrange with range
In Py2 `range` returns a list and `xrange` creates a sequence object that evaluates lazily. In Py3 `range` is equivalent to `xrange` in Py2. Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
7064cbaa35
commit
c36b5dab05
@ -625,7 +625,7 @@ class coredump_generator:
|
||||
off = 0# in pages
|
||||
for m in pagemap[1:]:
|
||||
found = False
|
||||
for i in xrange(m["nr_pages"]):
|
||||
for i in range(m["nr_pages"]):
|
||||
if m["vaddr"] + i*PAGESIZE == page_no*PAGESIZE:
|
||||
found = True
|
||||
break
|
||||
|
@ -19,13 +19,13 @@ def mix(nr_tasks, nr_pipes):
|
||||
|
||||
# First -- make a full set of combinations for a single pipe.
|
||||
max_idx = 1 << nr_tasks
|
||||
pipe_mix = [[(r, w)] for r in xrange(0, max_idx) for w in xrange(0, max_idx)]
|
||||
pipe_mix = [[(r, w)] for r in range(0, max_idx) for w in range(0, max_idx)]
|
||||
|
||||
# Now, for every pipe throw another one into the game making
|
||||
# all possible combinations of what was seen before with the
|
||||
# newbie.
|
||||
pipes_mix = pipe_mix
|
||||
for t in xrange(1, nr_pipes):
|
||||
for t in range(1, nr_pipes):
|
||||
pipes_mix = [ o + n for o in pipes_mix for n in pipe_mix ]
|
||||
|
||||
return pipes_mix
|
||||
@ -38,7 +38,7 @@ def make_pipes(task_nr, nr_pipes, pipes, comb, status_pipe):
|
||||
# We need to make sure that pipes have their
|
||||
# ends according to comb for task_nr
|
||||
|
||||
for i in xrange(0, nr_pipes):
|
||||
for i in range(0, nr_pipes):
|
||||
# Read end
|
||||
if not (comb[i][0] & (1 << task_nr)):
|
||||
os.close(pipes[i][0])
|
||||
@ -137,13 +137,13 @@ def make_comb(comb, opts, status_pipe):
|
||||
print('\tMake pipes')
|
||||
# 1st -- make needed pipes
|
||||
pipes = []
|
||||
for p in xrange(0, opts.pipes):
|
||||
for p in range(0, opts.pipes):
|
||||
pipes.append(os.pipe())
|
||||
|
||||
# Fork the kids that'll make pipes
|
||||
kc_pipe = os.pipe()
|
||||
kids = []
|
||||
for t in xrange(0, opts.tasks):
|
||||
for t in range(0, opts.tasks):
|
||||
pid = os.fork()
|
||||
if pid == 0:
|
||||
os.close(status_pipe)
|
||||
|
@ -23,7 +23,7 @@ root = tempfile.mkdtemp(prefix = "root.mount", dir = "/tmp")
|
||||
mount(None, root, 1, 0, 0)
|
||||
mounts = [root]
|
||||
|
||||
for i in xrange(10):
|
||||
for i in range(10):
|
||||
dstdir = random.choice(mounts)
|
||||
dst = tempfile.mkdtemp(prefix = "mount", dir = dstdir)
|
||||
src = random.choice(mounts + [None])
|
||||
|
Loading…
x
Reference in New Issue
Block a user