From 4e6bf8051eef297d139302205c7fbdece32f49f0 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Fri, 18 Oct 2013 09:52:02 -0700 Subject: Better Py2/3 support --- jsonschema/exceptions.py | 6 ++++-- 1 file 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__ -- cgit v1.2.1