From e802be7520acec0d181ab442922ea11f986c3e4e Mon Sep 17 00:00:00 2001 From: David Lord Date: Sat, 17 Apr 2021 18:17:35 -0700 Subject: [PATCH] fix Markup subclass str subclass must override __new__ instead of __init__ --- src/jinja2/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jinja2/utils.py b/src/jinja2/utils.py index 96c0d19a0..51e03d835 100644 --- a/src/jinja2/utils.py +++ b/src/jinja2/utils.py @@ -833,14 +833,14 @@ def __repr__(self): class Markup(markupsafe.Markup): - def __init__(self, *args, **kwargs): + def __new__(cls, base, encoding=None, errors="strict"): warnings.warn( "'jinja2.Markup' is deprecated and will be removed in Jinja" " 3.1. Import 'markupsafe.Markup' instead.", DeprecationWarning, stacklevel=2, ) - super().__init__(*args, **kwargs) + return super().__new__(cls, base, encoding, errors) def escape(s):