From patchwork Tue Mar 29 18:13:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,8] httpclient: handle io/cStringIO divergence From: timeless@mozdev.org X-Patchwork-Id: 14154 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Tue, 29 Mar 2016 13:13:06 -0500 # HG changeset patch # User timeless # 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])