From: Ben Darnell Date: Thu, 24 Feb 2011 00:59:49 +0000 (-0800) Subject: Fix references to str() type for python3 X-Git-Tag: v2.0.0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6822bb742edc562873e72a5a32626061137a77f8;p=thirdparty%2Ftornado.git Fix references to str() type for python3 --- diff --git a/tornado/escape.py b/tornado/escape.py index 3a810da6f..752c90951 100644 --- a/tornado/escape.py +++ b/tornado/escape.py @@ -21,6 +21,10 @@ import re import xml.sax.saxutils import urllib +# Python3 compatibility: On python2.5, introduce the bytes alias from 2.6 +try: bytes +except: bytes = str + # json module is in the standard library as of python 2.6; fall back to # simplejson if present for older versions. try: @@ -93,7 +97,7 @@ def utf8(value): return None if isinstance(value, unicode): return value.encode("utf-8") - assert isinstance(value, str) + assert isinstance(value, bytes) return value @@ -185,7 +189,7 @@ def linkify(text, shorten=False, extra_params="", def _unicode(value): - if isinstance(value, str): + if isinstance(value, bytes): return value.decode("utf-8") assert isinstance(value, unicode) return value