Skip to content

Commit

Permalink
Fix references to str() type for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Feb 24, 2011
1 parent a72cc17 commit 6822bb7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tornado/escape.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
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:
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -185,7 +189,7 @@ def make_link(m):


def _unicode(value):
if isinstance(value, str):
if isinstance(value, bytes):
return value.decode("utf-8")
assert isinstance(value, unicode)
return value
Expand Down

0 comments on commit 6822bb7

Please sign in to comment.