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

timeless timeless at mozdev.org
Wed Mar 30 00:33:19 EDT 2016


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

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])


More information about the Mercurial-devel mailing list