Patchwork [09,of,12] hgweb: remove handling of any else than strings from request.write

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 11, 2013, 11:32 p.m.
Message ID <cb969323468b05ce085d.1357947173@mk-desktop>
Download mbox | patch
Permalink /patch/569/
State Accepted
Commit c0d63e1884a3fc7bbf59988beac703f9408b7aef
Headers show

Comments

Mads Kiilerich - Jan. 11, 2013, 11:32 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1357947109 -3600
# Node ID cb969323468b05ce085de63865cdd4c08fb8f994
# Parent  a2ec86a8062c4aff9191f60a2eae08887f6f7c76
hgweb: remove handling of any else than strings from request.write

Iterators should be returned WSGI style, not written. And apparently all of
hgweb do that.

Patch

diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py
--- a/mercurial/hgweb/request.py
+++ b/mercurial/hgweb/request.py
@@ -109,16 +109,11 @@ 
             self.server_write = None
 
     def write(self, thing):
-        if util.safehasattr(thing, "__iter__"):
-            for part in thing:
-                self.write(part)
-        else:
-            thing = str(thing)
-            try:
-                self.server_write(thing)
-            except socket.error, inst:
-                if inst[0] != errno.ECONNRESET:
-                    raise
+        try:
+            self.server_write(thing)
+        except socket.error, inst:
+            if inst[0] != errno.ECONNRESET:
+                raise
 
     def writelines(self, lines):
         for line in lines: