From cefe133d2d0a5ca77ef556df268f2a3cae16f4c4 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Sat, 12 Oct 2024 14:16:41 +0200 Subject: [PATCH] fix: touni() should recognize bytearray --- bottle.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bottle.py b/bottle.py index 12a52b12..0f1191d5 100755 --- a/bottle.py +++ b/bottle.py @@ -127,9 +127,9 @@ def tob(s, enc='utf8'): def touni(s, enc='utf8', err='strict'): - if isinstance(s, bytes): - return s.decode(enc, err) - return unicode("" if s is None else s) + if isinstance(s, (bytes, bytearray)): + return str(s, enc, err) + return "" if s is None else str(s) def _stderr(*args):