[PATCH 7 of 9] util: use `iter(callable, sentinel)` instead of while True
Augie Fackler
raf at durin42.com
Sat Aug 6 11:02:37 EDT 2016
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1470420046 14400
# Fri Aug 05 14:00:46 2016 -0400
# Node ID d121b305f9bec087d568f1f53a8808e951e6d4ba
# Parent cfdfe5d1d84a5cbcd59575f0344fbc52863bf801
util: use `iter(callable, sentinel)` instead of while True
This is functionally equivalent, but is a little more concise.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1012,10 +1012,7 @@ def system(cmd, environ=None, cwd=None,
proc = subprocess.Popen(cmd, shell=True, close_fds=closefds,
env=env, cwd=cwd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- while True:
- line = proc.stdout.readline()
- if not line:
- break
+ for line in iter(proc.stdout.readline, ''):
out.write(line)
proc.wait()
rc = proc.returncode
More information about the Mercurial-devel
mailing list