Include the traceback only in RPC responses in development mode
Closes #14354 (grafted from 8693a06919f2ceac1aa9f36ab6069325198ec94b) --HG-- branch : 6.0
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -66,6 +66,7 @@ with commandline.pidfile(options):
|
||||
'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
|
||||
|
||||
@@ -169,7 +169,9 @@ class JSONProtocol:
|
||||
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:
|
||||
|
||||
@@ -65,6 +65,7 @@ class TrytondWSGI(object):
|
||||
})
|
||||
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 @@ class TrytondWSGI(object):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user