Skip to content

Commit

Permalink
python: futurize -f libfuturize.fixes.fix_next_call
Browse files Browse the repository at this point in the history
Change obj.next() calls to next(obj).

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_next_call $py

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20180608122952.2009-4-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
ehabkost committed Jun 8, 2018
1 parent 068cf7a commit d24d523
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/ordereddict.py
Expand Up @@ -71,9 +71,9 @@ def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = reversed(self).next()
key = next(reversed(self))
else:
key = iter(self).next()
key = next(iter(self))
value = self.pop(key)
return key, value

Expand Down
4 changes: 2 additions & 2 deletions scripts/vmstate-static-checker.py
Expand Up @@ -158,7 +158,7 @@ def check_fields(src_fields, dest_fields, desc, sec):
while True:
if advance_src:
try:
s_item = s_iter.next()
s_item = next(s_iter)
except StopIteration:
if s_iter_list == []:
break
Expand All @@ -173,7 +173,7 @@ def check_fields(src_fields, dest_fields, desc, sec):

if advance_dest:
try:
d_item = d_iter.next()
d_item = next(d_iter)
except StopIteration:
if d_iter_list == []:
# We were not in a substruct
Expand Down
2 changes: 1 addition & 1 deletion tests/image-fuzzer/runner.py
Expand Up @@ -422,7 +422,7 @@ def should_continue(duration, start_time):
test_id = count(1)
while should_continue(duration, start_time):
try:
run_test(str(test_id.next()), seed, work_dir, run_log, cleanup,
run_test(str(next(test_id)), seed, work_dir, run_log, cleanup,
log_all, command, config)
except (KeyboardInterrupt, SystemExit):
sys.exit(1)
Expand Down

0 comments on commit d24d523

Please sign in to comment.