From 7b0b7292aa704b95ffe2b4f3bd58ce8f954de1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 30 Sep 2023 19:55:24 +0200 Subject: [PATCH] Use fallback value for charset, url_charset and encoding_errors Werkzeug 3.0 removes those attributes. Closes #12604 (grafted from 0f5c7ceb4ea70a844ee660a678cc0b2b4643167e) --HG-- branch : 6.0 --- trytond/trytond/protocols/jsonrpc.py | 3 ++- trytond/trytond/protocols/wrappers.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/trytond/trytond/protocols/jsonrpc.py b/trytond/trytond/protocols/jsonrpc.py index 5a0ea6ee1a..988d8b24ef 100644 --- a/trytond/trytond/protocols/jsonrpc.py +++ b/trytond/trytond/protocols/jsonrpc.py @@ -126,7 +126,8 @@ class JSONRequest(Request): try: return json.loads( self.decoded_data.decode( - self.charset, self.encoding_errors), + getattr(self, 'charset', 'utf-8'), + getattr(self, 'encoding_errors', 'replace')), object_hook=JSONDecoder()) except Exception: raise BadRequest('Unable to read JSON request') diff --git a/trytond/trytond/protocols/wrappers.py b/trytond/trytond/protocols/wrappers.py index 4bf107cc8e..57ac7b4153 100644 --- a/trytond/trytond/protocols/wrappers.py +++ b/trytond/trytond/protocols/wrappers.py @@ -35,7 +35,7 @@ class Request(_Request): if self.url is None or isinstance(self.url, str): url = self.url else: - url = self.url.decode(self.url_charset) + url = self.url.decode(getattr(self, 'url_charset', 'utf-8')) auth = self.authorization if auth: args.append("%s@%s" % (