Commit a8d489d4 authored by Rémi Cardona's avatar Rémi Cardona
Browse files

[py3k] Replace uses of 'unicode' and 'str'

Related to #268148.
parent bf4de921620e
......@@ -38,6 +38,7 @@ import string
import codecs
from io import BytesIO
from six import text_type, binary_type
from six.moves.html_entities import name2codepoint
......@@ -136,7 +137,7 @@ def html_escape(data):
def xml_escape(data):
"""escapes XML forbidden characters in attributes and PCDATA"""
if isinstance(data, unicode):
if isinstance(data, text_type):
data = data.translate(ESC_UCAR_TABLE)
data = data.translate(ESC_CAR_TABLE)
......@@ -158,7 +159,7 @@ class TransformData(object): = data
self.mimetype = mimetype
self.encoding = encoding
if not self.is_binary() and not encoding and not isinstance(, unicode):
if not self.is_binary() and not encoding and not isinstance(, text_type):
self.encoding = guess_encoding(data)
def get(self, attr, default=None):
......@@ -167,7 +168,7 @@ class TransformData(object):
def decode(self, force=False):
"""return the data as an unicode string"""
if isinstance(, unicode):
if isinstance(, text_type):
if force:
if self.encoding in BINARY_ENCODINGS:
......@@ -184,7 +185,7 @@ class TransformData(object):
def encode(self, encoding=None):
"""return the data as an encoded string"""
if (encoding is None or self.encoding == encoding) and \
isinstance(, str):
isinstance(, binary_type):
encoding = encoding or self.encoding or 'utf8'
return self.decode().encode(encoding)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment