summaryrefslogtreecommitdiff
path: root/django/utils/html.py
diff options
context:
space:
mode:
authordevilsautumn <bhuvnesh875@gmail.com>2023-06-06 14:26:53 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-06-06 14:14:57 +0200
commit094b0bea2ce76db9d3dc06c384d4ac3b22705810 (patch)
tree3a6745cd3020b7e91c2d0ebd905b6327a7b0cea8 /django/utils/html.py
parent4f6a51dfe6a4a8d5ed61c73b902e808109f142b0 (diff)
Fixed #34609 -- Deprecated calling format_html() without arguments.
Diffstat (limited to 'django/utils/html.py')
-rw-r--r--django/utils/html.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index c32a36fa93..56d65a8d21 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -3,9 +3,11 @@
import html
import json
import re
+import warnings
from html.parser import HTMLParser
from urllib.parse import parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit
+from django.utils.deprecation import RemovedInDjango60Warning
from django.utils.encoding import punycode
from django.utils.functional import Promise, keep_lazy, keep_lazy_text
from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS
@@ -100,6 +102,13 @@ def format_html(format_string, *args, **kwargs):
and call mark_safe() on the result. This function should be used instead
of str.format or % interpolation to build up small HTML fragments.
"""
+ if not (args or kwargs):
+ # RemovedInDjango60Warning: when the deprecation ends, replace with:
+ # raise ValueError("args or kwargs must be provided.")
+ warnings.warn(
+ "Calling format_html() without passing args or kwargs is deprecated.",
+ RemovedInDjango60Warning,
+ )
args_safe = map(conditional_escape, args)
kwargs_safe = {k: conditional_escape(v) for (k, v) in kwargs.items()}
return mark_safe(format_string.format(*args_safe, **kwargs_safe))