[exceptions] don't define __str__ in terms of unicode on py3k

Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changesetb530a2aa8c99
branchdefault
phasedraft
hiddenyes
parent revision#3e3735285323 [yams] deal with py3k string types and builtin module
child revision#57ee237b1f48 [buildobjs] deal with py3k's string types
files modified by this revision
_exceptions.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413451623 -7200
# Thu Oct 16 11:27:03 2014 +0200
# Node ID b530a2aa8c996f45235a2677845ef86ddb669407
# Parent 3e373528532321ab1dd9338e9e5c9ea0b53e0aa7
[exceptions] don't define __str__ in terms of unicode on py3k

Related to #267910.

diff --git a/_exceptions.py b/_exceptions.py
@@ -17,15 +17,18 @@
1  # with yams. If not, see <http://www.gnu.org/licenses/>.
2  """YAMS exception classes"""
3 
4  __docformat__ = "restructuredtext en"
5 
6 +import sys
7 +
8  class SchemaError(Exception):
9      """base class for schema exceptions"""
10 
11 -    def __str__(self):
12 -        return unicode(self).encode('utf8')
13 +    if sys.version_info[0] < 3:
14 +        def __str__(self):
15 +            return unicode(self).encode('utf8')
16 
17 
18  class UnknownType(SchemaError):
19      """using an unknown entity type"""
20