Created
August 2, 2017 12:59
-
-
Save sebalix/0b58a24cb5f02558bd2ef95bffa6bf36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/odoorpc/error.py b/odoorpc/error.py | |
index d359d7f..1ade192 100644 | |
--- a/odoorpc/error.py | |
+++ b/odoorpc/error.py | |
@@ -21,6 +21,16 @@ | |
"""This module contains all exceptions raised by `OdooRPC` when an error | |
occurred. | |
""" | |
+import sys | |
+ | |
+# Python 2 | |
+if sys.version_info[0] < 3: | |
+ def encode2str(data): | |
+ return data.encode('utf-8') | |
+# Python >= 3 | |
+else: | |
+ def encode2str(data): | |
+ return data | |
class Error(Exception): | |
@@ -78,7 +88,7 @@ class RPCError(Error): | |
True | |
""" | |
def __init__(self, message, info=False): | |
- super(Error, self).__init__(message, info) | |
+ super(Error, self).__init__(encode2str(message), info) | |
self.info = info | |
def __str__(self): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment