diff options
author | Vlastimil Zíma <vlastimil.zima@nic.cz> | 2018-05-02 11:58:26 +0200 |
---|---|---|
committer | Vlastimil Zíma <vlastimil.zima@nic.cz> | 2018-05-11 13:40:03 +0200 |
commit | 1082699a5be1111b439fa21fe0123d5f80f91cbd (patch) | |
tree | 42ee803f4410a0be7698ad3adcf75ab17be68e60 /openid/yadis | |
parent | 38e747ee7071a9af23edf0378028878c699fe512 (diff) | |
download | openid-1082699a5be1111b439fa21fe0123d5f80f91cbd.tar.gz |
Use StringIO and BytesIO from six
Diffstat (limited to 'openid/yadis')
-rw-r--r-- | openid/yadis/discover.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/openid/yadis/discover.py b/openid/yadis/discover.py index e1b494f..769fb74 100644 --- a/openid/yadis/discover.py +++ b/openid/yadis/discover.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from StringIO import StringIO +from six import BytesIO, StringIO from openid import fetchers from openid.yadis.constants import YADIS_ACCEPT_HEADER, YADIS_CONTENT_TYPE, YADIS_HEADER_NAME @@ -138,14 +138,14 @@ def whereIsYadis(resp): encoding = 'UTF-8' try: - content = resp.body.decode(encoding) + buff = StringIO(resp.body.decode(encoding)) except UnicodeError: # Keep encoded version in case yadis location can be found before encoding shut this up. # Possible errors will be caught lower. - content = resp.body + buff = BytesIO(resp.body) try: - yadis_loc = findHTMLMeta(StringIO(content)) + yadis_loc = findHTMLMeta(buff) except (MetaNotFound, UnicodeError): # UnicodeError: Response body could not be encoded and xrds location # could not be found before troubles occurs. |