mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-24 16:14:45 +00:00
Merge pull request #217 from cjmayo/python3_07
{python3_07} Python3: use BytesIO instead of StringIO
This commit is contained in:
commit
75626d456a
5 changed files with 12 additions and 9 deletions
|
|
@ -27,7 +27,7 @@ try: # Python 3
|
|||
except ImportError: # Python 2
|
||||
from httplib import HTTPMessage
|
||||
import requests
|
||||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
def from_file (filename):
|
||||
|
|
@ -58,7 +58,7 @@ def from_headers (strheader):
|
|||
@raises: ValueError for incomplete or invalid data
|
||||
"""
|
||||
res = []
|
||||
fp = StringIO(strheader)
|
||||
fp = BytesIO(strheader)
|
||||
headers = HTTPMessage(fp, seekable=True)
|
||||
if "Host" not in headers:
|
||||
raise ValueError("Required header 'Host:' missing")
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ A CSV logger.
|
|||
"""
|
||||
import csv
|
||||
import os
|
||||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
from . import _Logger
|
||||
from .. import strformat
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class CSVLogger (_Logger):
|
|||
else:
|
||||
# write empty string to initialize file output
|
||||
self.write(u"")
|
||||
self.queue = StringIO()
|
||||
self.queue = BytesIO()
|
||||
self.writer = csv.writer(self.queue, dialect=self.dialect,
|
||||
delimiter=self.separator, lineterminator=self.linesep,
|
||||
quotechar=self.quotechar)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Test cgi form routines.
|
|||
import unittest
|
||||
import wsgiref
|
||||
import urllib
|
||||
from StringIO import StringIO
|
||||
from io import BytesIO
|
||||
from wsgiref.util import setup_testing_defaults
|
||||
from linkcheck.lc_cgi import checkform, checklink, LCFormError, application
|
||||
from linkcheck.strformat import limit
|
||||
|
|
@ -59,7 +59,7 @@ class TestWsgi (unittest.TestCase):
|
|||
def test_application (self):
|
||||
form = dict(url="http://www.example.com/", level="0")
|
||||
formdata = urllib.urlencode(form)
|
||||
environ = {'wsgi.input': StringIO(formdata)}
|
||||
environ = {'wsgi.input': BytesIO(formdata)}
|
||||
setup_testing_defaults(environ)
|
||||
test_response = ""
|
||||
test_headers = [None]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Test decorators.
|
|||
|
||||
import unittest
|
||||
import time
|
||||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
import linkcheck.decorators
|
||||
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ class TestDecorators (unittest.TestCase):
|
|||
self.assertEqual(f(), 42)
|
||||
|
||||
def test_timeit2 (self):
|
||||
log = StringIO()
|
||||
log = BytesIO()
|
||||
@linkcheck.decorators.timed(log=log, limit=0)
|
||||
def f ():
|
||||
time.sleep(1)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ Test html parsing.
|
|||
|
||||
import linkcheck.HtmlParser.htmlsax
|
||||
import linkcheck.HtmlParser.htmllib
|
||||
from cStringIO import StringIO
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
import unittest
|
||||
|
||||
from parameterized import parameterized
|
||||
|
|
|
|||
Loading…
Reference in a new issue