Patchwork [4,of,8,v2] httpclient: handle io/cStringIO divergence

login
register
mail settings
Submitter timeless@mozdev.org
Date March 30, 2016, 4:33 a.m.
Message ID <b2205d49ee6f9a8c6ce8.1459312399@waste.org>
Download mbox | patch
Permalink /patch/14165/
State Accepted
Headers show

Comments

timeless@mozdev.org - March 30, 2016, 4:33 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1459200608 0
#      Mon Mar 28 21:30:08 2016 +0000
# Node ID b2205d49ee6f9a8c6ce8316bce8fd25e5d593775
# Parent  7c1f1230c392146666387287483147e3a7aaec66
httpclient: handle io/cStringIO divergence

Patch

diff --git a/mercurial/httpclient/__init__.py b/mercurial/httpclient/__init__.py
--- a/mercurial/httpclient/__init__.py
+++ b/mercurial/httpclient/__init__.py
@@ -41,7 +41,6 @@ 
 # Many functions in this file have too many arguments.
 # pylint: disable=R0913
 
-import cStringIO
 import errno
 import httplib
 import logging
@@ -49,6 +48,11 @@ 
 import select
 import socket
 
+try:
+    import cStringIO as io
+except ImportError:
+    import io
+
 from . import (
     _readers,
     socketutil,
@@ -242,7 +246,7 @@ 
         self.status = int(self.status)
         if self._eol != EOL:
             hdrs = hdrs.replace(self._eol, '\r\n')
-        headers = rfc822.Message(cStringIO.StringIO(hdrs))
+        headers = rfc822.Message(io.StringIO(hdrs))
         content_len = None
         if HDR_CONTENT_LENGTH in headers:
             content_len = int(headers[HDR_CONTENT_LENGTH])