Reviewers: ,


Please review this at http://codereview.tryton.org/225001/

Affected files:
  M trytond/convert.py
  M trytond/ir/cron.py
  M trytond/model/modelstorage.py
  M trytond/protocols/dispatcher.py
  M trytond/protocols/jsonrpc.py
  M trytond/protocols/webdav.py
  M trytond/protocols/xmlrpc.py


Index: trytond/convert.py
===================================================================

--- a/trytond/convert.py
+++ b/trytond/convert.py
@@ -983,8 +983,7 @@
             cursor.commit()
         except Exception:
             cursor.rollback()
-            tb_s = reduce(lambda x, y: x + y,
-                    traceback.format_exception(*sys.exc_info()))
+            tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
             logging.getLogger("convert").error(
                 'Could not delete id: %d of model %s\n'
                     'There should be some relation '
@@ -992,7 +991,7 @@
                     'You should manually fix this '
                     'and restart --update=module\n'
                     'Exception: %s' %
-                    (db_id, model, tb_s.decode('utf-8', 'ignore')))
+                    (db_id, model, tb_s))

     transition_obj = pool.get('workflow.transition')
     for mdata_id, db_id in transition_delete:

Index: trytond/ir/cron.py
===================================================================

--- a/trytond/ir/cron.py
+++ b/trytond/ir/cron.py
@@ -104,8 +104,7 @@
         return _INTERVALTYPES[cron.interval_type](cron.interval_number)

     def _get_request_values(self, cron):
-        tb_s = reduce(lambda x, y: x + y,
-                traceback.format_exception(*sys.exc_info()))
+        tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
         tb_s = tb_s.decode('utf-8', 'ignore')
         name = self.raise_user_error('request_title',
             raise_exception=False)

Index: trytond/model/modelstorage.py
===================================================================

--- a/trytond/model/modelstorage.py
+++ b/trytond/model/modelstorage.py
@@ -857,8 +857,7 @@
                 logger.error(exp)
                 # XXX should raise Exception
                 Transaction().cursor.rollback()
-                tb_s = reduce(lambda x, y: x + y,
-                        traceback.format_exception(*sys.exc_info()))
+                tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
                 warning = '%s\n%s' % (tb_s, warning)
                 return (-1, res, exp, warning)
             done += 1

Index: trytond/protocols/dispatcher.py
===================================================================

--- a/trytond/protocols/dispatcher.py
+++ b/trytond/protocols/dispatcher.py
@@ -165,13 +165,12 @@
                 if CONFIG['verbose'] and not isinstance(exception, (
                             NotLogged, ConcurrencyException, UserError,
                             UserWarning)):
-                    tb_s = reduce(lambda x, y: x + y,
-                            traceback.format_exception(*sys.exc_info()))
+ tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
                     logger = logging.getLogger('dispatcher')
                     logger.error('Exception calling method %s on ' \
                             '%s %s from %s@%s:%d/%s:\n' % \
(method, object_type, object_name, user, host, port, - database_name) + tb_s.decode('utf-8', 'ignore'))
+                                database_name) + tb_s)
                 transaction.cursor.rollback()
                 raise
         if not (object_name == 'res.request' and method == 'request_get'):
@@ -236,8 +235,7 @@
             res = True
     except Exception:
         logger.error('CREATE DB: %s failed' % (database_name,))
-        tb_s = reduce(lambda x, y: x+y,
-                traceback.format_exception(*sys.exc_info()))
+        tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
         logger.error('Exception in call: \n' + tb_s)
         raise
     else:
@@ -259,8 +257,7 @@
             cursor.commit()
         except Exception:
             logger.error('DROP DB: %s failed' % (database_name,))
-            tb_s = reduce(lambda x, y: x+y,
-                    traceback.format_exception(*sys.exc_info()))
+            tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
             logger.error('Exception in call: \n' + tb_s)
             raise
         else:

Index: trytond/protocols/jsonrpc.py
===================================================================

--- a/trytond/protocols/jsonrpc.py
+++ b/trytond/protocols/jsonrpc.py
@@ -111,13 +111,7 @@
                 ConcurrencyException), exception:
             response['error'] = exception.args
         except Exception:
-            tb_s = ''
-            for line in traceback.format_exception(*sys.exc_info()):
-                try:
-                    line = line.encode('utf-8', 'ignore')
-                except Exception:
-                    continue
-                tb_s += line
+            tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
             for path in sys.path:
                 tb_s = tb_s.replace(path, '')
             if CONFIG['debug_mode']:

Index: trytond/protocols/webdav.py
===================================================================

--- a/trytond/protocols/webdav.py
+++ b/trytond/protocols/webdav.py
@@ -137,10 +137,9 @@
         if CONFIG['verbose'] and not isinstance(exception, (
NotLogged, ConcurrencyException, UserError, UserWarning,
                     DAV_Error, DAV_NotFound, DAV_Secret, DAV_Forbidden)):
-            tb_s = reduce(lambda x, y: x + y,
-                traceback.format_exception(*sys.exc_info()))
+            tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
             logger = logging.getLogger('webdav')
-            logger.error('Exception:\n' + tb_s.decode('utf-8', 'ignore'))
+            logger.error('Exception:\n' + tb_s)

     @staticmethod
     def get_dburi(uri):

Index: trytond/protocols/xmlrpc.py
===================================================================

--- a/trytond/protocols/xmlrpc.py
+++ b/trytond/protocols/xmlrpc.py
@@ -113,13 +113,7 @@
                 raise xmlrpclib.Fault(exception.code,
                     '\n'.join((error,) + description))
             except Exception:
-                tb_s = ''
-                for line in traceback.format_exception(*sys.exc_info()):
-                    try:
-                        line = line.encode('utf-8', 'ignore')
-                    except Exception:
-                        continue
-                    tb_s += line
+                tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
                 for path in sys.path:
                     tb_s = tb_s.replace(path, '')
                 if CONFIG['debug_mode']:



--
[email protected] mailing list

Reply via email to