From 5a9041d393f568f3a94157eca7d104d5ed4906f3 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 9 Sep 2018 16:41:40 -0700 Subject: [PATCH] Prefer io.BytesIO over six; available on all supported Pythons (#1435) On all supported Pythons, the io.BytesIO is always a stream implementation using an in-memory bytes buffer. Makes code slightly more forward compatible by reducing use of the six module. --- src/urllib3/contrib/appengine.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/urllib3/contrib/appengine.py b/src/urllib3/contrib/appengine.py index 66922e06aa..b2951cf8eb 100644 --- a/src/urllib3/contrib/appengine.py +++ b/src/urllib3/contrib/appengine.py @@ -39,6 +39,7 @@ """ from __future__ import absolute_import +import io import logging import os import warnings @@ -53,7 +54,6 @@ SSLError ) -from ..packages.six import BytesIO from ..request import RequestMethods from ..response import HTTPResponse from ..util.timeout import Timeout @@ -239,7 +239,7 @@ def _urlfetch_response_to_http_response(self, urlfetch_resp, **response_kw): original_response = HTTPResponse( # In order for decoding to work, we must present the content as # a file-like object. - body=BytesIO(urlfetch_resp.content), + body=io.BytesIO(urlfetch_resp.content), msg=urlfetch_resp.header_msg, headers=urlfetch_resp.headers, status=urlfetch_resp.status_code, @@ -247,7 +247,7 @@ def _urlfetch_response_to_http_response(self, urlfetch_resp, **response_kw): ) return HTTPResponse( - body=BytesIO(urlfetch_resp.content), + body=io.BytesIO(urlfetch_resp.content), headers=urlfetch_resp.headers, status=urlfetch_resp.status_code, original_response=original_response,