add file_size
[odoo/odoo.git] / openerp / loglevels.py
index 8973453..f4fa469 100644 (file)
@@ -131,12 +131,13 @@ def ustr(value, hint_encoding='utf-8', errors='strict'):
         upstream and should be tried first to decode ``value``.
     :param str error: optional `errors` flag to pass to the unicode
         built-in to indicate how illegal character values should be
-        treated: 'strict', 'ignore' or 'replace'. Passing anything
-        other than 'strict' means that the first encoding tried will
-        succeed, even if it's not the correct one to use, so be
-        careful!
-    :rtype: unicode
+        treated when converting a string: 'strict', 'ignore' or 'replace'
+        (see ``unicode()`` constructor).
+        Passing anything other than 'strict' means that the first
+        encoding tried will be used, even if it's not the correct
+        one to use, so be careful! Ignored if value is not a string/unicode.
     :raise: UnicodeError if value cannot be coerced to unicode
+    :return: unicode string representing the given value
     """
     if isinstance(value, Exception):
         return exception_to_unicode(value)
@@ -146,7 +147,7 @@ def ustr(value, hint_encoding='utf-8', errors='strict'):
 
     if not isinstance(value, basestring):
         try:
-            return unicode(value, errors=errors)
+            return unicode(value)
         except Exception:
             raise UnicodeError('unable to convert %r' % (value,))
 
@@ -158,13 +159,13 @@ def ustr(value, hint_encoding='utf-8', errors='strict'):
     raise UnicodeError('unable to convert %r' % (value,))
 
 
-def exception_to_unicode(e, errors='strict'):
+def exception_to_unicode(e):
     if (sys.version_info[:2] < (2,6)) and hasattr(e, 'message'):
         return ustr(e.message)
     if hasattr(e, 'args'):
-        return "\n".join((ustr(a, errors=errors) for a in e.args))
+        return "\n".join((ustr(a) for a in e.args))
     try:
-        return unicode(e, errors=errors)
+        return unicode(e)
     except Exception:
         return u"Unknown message"