details: https://code.tryton.org/tryton/commit/6b5800b66a5d
branch: 6.0
user: Cédric Krier <[email protected]>
date: Wed Nov 12 14:56:34 2025 +0100
description:
Include the traceback only in RPC responses in development mode
Closes #14354
(grafted from 8693a06919f2ceac1aa9f36ab6069325198ec94b)
diffstat:
trytond/CHANGELOG | 1 +
trytond/bin/trytond | 1 +
trytond/trytond/protocols/jsonrpc.py | 4 +++-
trytond/trytond/wsgi.py | 10 ++++++----
4 files changed, 11 insertions(+), 5 deletions(-)
diffs (60 lines):
diff -r 166ec9813a8b -r 6b5800b66a5d trytond/CHANGELOG
--- a/trytond/CHANGELOG Mon Nov 17 10:28:49 2025 +0100
+++ b/trytond/CHANGELOG Wed Nov 12 14:56:34 2025 +0100
@@ -1,3 +1,4 @@
+* Include the traceback only in RPC responses in development mode (issue14354)
* Enforce access check in HTML editor route (issue14364)
Version 6.0.69 - 2025-11-02
diff -r 166ec9813a8b -r 6b5800b66a5d trytond/bin/trytond
--- a/trytond/bin/trytond Mon Nov 17 10:28:49 2025 +0100
+++ b/trytond/bin/trytond Wed Nov 12 14:56:34 2025 +0100
@@ -66,6 +66,7 @@
'txt', 'html', 'xhtml']:
path = os.path.join(info['directory'], '**', '*.' + ext)
extra_files.extend(glob.glob(path, recursive=True))
+ app.dev = options.dev
if options.coroutine:
from gevent.pywsgi import WSGIServer
diff -r 166ec9813a8b -r 6b5800b66a5d trytond/trytond/protocols/jsonrpc.py
--- a/trytond/trytond/protocols/jsonrpc.py Mon Nov 17 10:28:49 2025 +0100
+++ b/trytond/trytond/protocols/jsonrpc.py Wed Nov 12 14:56:34 2025 +0100
@@ -169,7 +169,9 @@
response['error'] = data.args
elif isinstance(data, Exception):
# report exception back to server
- response['error'] = (str(data), data.__format_traceback__)
+ response['error'] = (
+ str(data),
+ getattr(data, '__format_traceback__', ''))
else:
response['result'] = data
else:
diff -r 166ec9813a8b -r 6b5800b66a5d trytond/trytond/wsgi.py
--- a/trytond/trytond/wsgi.py Mon Nov 17 10:28:49 2025 +0100
+++ b/trytond/trytond/wsgi.py Wed Nov 12 14:56:34 2025 +0100
@@ -65,6 +65,7 @@
})
self.protocols = [JSONProtocol, XMLProtocol]
self.error_handlers = []
+ self.dev = False
def route(self, string, methods=None, defaults=None):
def decorator(func):
@@ -122,10 +123,11 @@
except Exception as e:
logger.debug(
"Exception when processing %s", request, exc_info=True)
- tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
- for path in sys.path:
- tb_s = tb_s.replace(path, '')
- e.__format_traceback__ = tb_s
+ if self.dev:
+ tb_s = ''.join(traceback.format_exception(*sys.exc_info()))
+ for path in sys.path:
+ tb_s = tb_s.replace(path, '')
+ e.__format_traceback__ = tb_s
response = e
for error_handler in self.error_handlers:
rv = error_handler(self, request, e)