Patchwork D888: keepalive: python 3 portability tweaks

login
register
mail settings
Submitter phabricator
Date Oct. 2, 2017, 4:21 p.m.
Message ID <9b9c76d1e054bc7ae0282222f32cc9e0@localhost.localdomain>
Download mbox | patch
Permalink /patch/24399/
State Not Applicable
Headers show

Comments

phabricator - Oct. 2, 2017, 4:21 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa454123f5d94: keepalive: python 3 portability tweaks (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D888?vs=2300&id=2335

REVISION DETAIL
  https://phab.mercurial-scm.org/D888

AFFECTED FILES
  mercurial/keepalive.py

CHANGE DETAILS




To: durin42, #hg-reviewers, yuja
Cc: mercurial-devel

Patch

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -92,6 +92,7 @@ 
 
 from .i18n import _
 from . import (
+    pycompat,
     util,
 )
 
@@ -235,7 +236,8 @@ 
         # The string form of BadStatusLine is the status line. Add some context
         # to make the error message slightly more useful.
         except httplib.BadStatusLine as err:
-            raise urlerr.urlerror(_('bad HTTP status line: %s') % err.line)
+            raise urlerr.urlerror(
+                _('bad HTTP status line: %s') % pycompat.sysbytes(err.line))
         except (socket.error, httplib.HTTPException) as err:
             raise urlerr.urlerror(err)
 
@@ -358,9 +360,12 @@ 
 
 
     def __init__(self, sock, debuglevel=0, strict=0, method=None):
+        extrakw = {}
+        if not pycompat.ispy3:
+            extrakw['strict'] = True
+            extrakw['buffering'] = True
         httplib.HTTPResponse.__init__(self, sock, debuglevel=debuglevel,
-                                      strict=True, method=method,
-                                      buffering=True)
+                                      method=method, **extrakw)
         self.fileno = sock.fileno
         self.code = None
         self._rbuf = ''