aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2012-11-28 00:09:17 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2012-11-28 00:09:17 +0100
commit03f9daab34605f538294fdffb141ef5d9fc670e6 (patch)
tree439c54799355ebef2d5e3e4face41b33cea14521 /youtube_dl/utils.py
parenta8156c1d2e4b2a7ac5e034c247c6fccaca15a21d (diff)
downloadyoutube-dl-03f9daab34605f538294fdffb141ef5d9fc670e6.tar.xz
Use io.BytesIO instead of StringIO
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index c4917012b..ebff2e8f2 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import gzip
+import io
import locale
import os
import re
@@ -11,11 +12,6 @@ import email.utils
import json
try:
- import cStringIO as StringIO
-except ImportError:
- import StringIO
-
-try:
import urllib.request as compat_urllib_request
except ImportError: # Python 2
import urllib2 as compat_urllib_request
@@ -400,12 +396,12 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
old_resp = resp
# gzip
if resp.headers.get('Content-encoding', '') == 'gzip':
- gz = gzip.GzipFile(fileobj=StringIO.StringIO(resp.read()), mode='r')
+ gz = gzip.GzipFile(fileobj=io.BytesIO(resp.read()), mode='r')
resp = self.addinfourl_wrapper(gz, old_resp.headers, old_resp.url, old_resp.code)
resp.msg = old_resp.msg
# deflate
if resp.headers.get('Content-encoding', '') == 'deflate':
- gz = StringIO.StringIO(self.deflate(resp.read()))
+ gz = io.BytesIO(self.deflate(resp.read()))
resp = self.addinfourl_wrapper(gz, old_resp.headers, old_resp.url, old_resp.code)
resp.msg = old_resp.msg
return resp