summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Anderson <sontek@gmail.com>2013-10-18 09:52:02 -0700
committerJohn Anderson <sontek@gmail.com>2013-10-18 09:52:02 -0700
commit4e6bf8051eef297d139302205c7fbdece32f49f0 (patch)
tree1a7362dcc90de0b7b599c0d84e3820fc4fdf8590
parenta324c1fc19b6ae49da879f804c8e20b8a6d34db7 (diff)
downloadjsonschema-4e6bf8051eef297d139302205c7fbdece32f49f0.tar.gz
Better Py2/3 support
-rw-r--r--jsonschema/exceptions.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py
index c6e5ad9..5d49410 100644
--- a/jsonschema/exceptions.py
+++ b/jsonschema/exceptions.py
@@ -99,13 +99,13 @@ class UnknownType(Exception):
self.schema = schema
def __str__(self):
- return self.__unicode__()
+ return unicode(self).encode("utf-8")
def __unicode__(self):
pschema = pprint.pformat(self.schema, width=72)
pinstance = pprint.pformat(self.instance, width=72)
return textwrap.dedent("""
- Uknown Type: %s, in schema:
+ Unknown Type: %r, in schema:
%s
On instance:
@@ -115,6 +115,8 @@ class UnknownType(Exception):
_utils.indent(pschema),
_utils.indent(pinstance))
+ if PY3:
+ __str__ = __unicode__