Patchwork [5,of,9] sshserver: use `iter(callable, sentinel)` instead of while True

login
register
mail settings
Submitter Augie Fackler
Date Aug. 6, 2016, 3:02 p.m.
Message ID <07c773056e724ba6e1e7.1470495755@imladris.local>
Download mbox | patch
Permalink /patch/16159/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 6, 2016, 3:02 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1470420030 14400
#      Fri Aug 05 14:00:30 2016 -0400
# Node ID 07c773056e724ba6e1e753635909e968026cffb3
# Parent  5fbdb186660f4c93905498e4a1a5f71d7a0cd7ec
sshserver: use `iter(callable, sentinel)` instead of while True

This is functionally equivalent, but is a little more concise.

Patch

diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -69,11 +69,7 @@  class sshserver(wireproto.abstractserver
         pass
 
     def groupchunks(self, changegroup):
-        while True:
-            d = changegroup.read(4096)
-            if not d:
-                break
-            yield d
+        return iter(lambda: changegroup.read(4096), '')
 
     def sendresponse(self, v):
         self.fout.write("%d\n" % len(v))