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

Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset704215d49a58
branchdefault
phasepublic
hiddenno
parent revision#18791c4c4ae2 [yams] deal with py3k string types and builtin module
child revision#32c4bc375ae0 [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 704215d49a5800314a77e82239cc74ddbe6745eb
# Parent 18791c4c4ae28dd99ddeb6ef44600668cc7cbfa0
[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