From e8d0d2a5efc8012dcc8bf1809dec065ebde64c81 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 1 Aug 2019 05:30:20 -0700 Subject: [PATCH] Removed unneeded ValueError catching in django.utils.text._replace_entity(). The html.entities.name2codepoint dict contains only valid Unicode codepoints. Either the key exists and chr() will succeed or the key does not exist. --- django/utils/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/utils/text.py b/django/utils/text.py index c2576b012a..03e2d05177 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -351,7 +351,7 @@ def _replace_entity(match): else: try: return chr(html.entities.name2codepoint[text]) - except (ValueError, KeyError): + except KeyError: return match.group(0)