summaryrefslogtreecommitdiff
path: root/jsonschema/exceptions.py
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2016-11-27 11:24:05 -0500
committerJulian Berman <Julian@GrayVines.com>2016-11-27 11:25:17 -0500
commitee2de6d0e0b6fed6f580cf2d744fb2790fe06a54 (patch)
tree43f1e750409d5f3d51f9de3a4d781d7aa4f568df /jsonschema/exceptions.py
parente7d2975b08281fb209f03a01e1fb6972fd79e978 (diff)
downloadjsonschema-ee2de6d0e0b6fed6f580cf2d744fb2790fe06a54.tar.gz
More style fun.
Diffstat (limited to 'jsonschema/exceptions.py')
-rw-r--r--jsonschema/exceptions.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py
index 829034c..da3e852 100644
--- a/jsonschema/exceptions.py
+++ b/jsonschema/exceptions.py
@@ -56,9 +56,6 @@ class _Error(Exception):
def __repr__(self):
return "<%s: %r>" % (self.__class__.__name__, self.message)
- def __str__(self):
- return unicode(self).encode("utf-8")
-
def __unicode__(self):
essential_for_verbose = (
self.validator, self.validator_value, self.instance, self.schema,
@@ -86,6 +83,9 @@ class _Error(Exception):
if PY3:
__str__ = __unicode__
+ else:
+ def __str__(self):
+ return unicode(self).encode("utf-8")
@classmethod
def create_from(cls, other):
@@ -142,9 +142,6 @@ class UnknownType(Exception):
self.instance = instance
self.schema = schema
- def __str__(self):
- return unicode(self).encode("utf-8")
-
def __unicode__(self):
pschema = pprint.pformat(self.schema, width=72)
pinstance = pprint.pformat(self.instance, width=72)
@@ -159,7 +156,9 @@ class UnknownType(Exception):
if PY3:
__str__ = __unicode__
-
+ else:
+ def __str__(self):
+ return unicode(self).encode("utf-8")
class FormatError(Exception):
@@ -168,14 +167,14 @@ class FormatError(Exception):
self.message = message
self.cause = self.__cause__ = cause
- def __str__(self):
- return self.message.encode("utf-8")
-
def __unicode__(self):
return self.message
if PY3:
__str__ = __unicode__
+ else:
+ def __str__(self):
+ return self.message.encode("utf-8")
class ErrorTree(object):