From ff308a06047cd60806d604a7cf612e5656ee2ac9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 29 May 2024 14:48:27 +0100 Subject: Fixed 35467 -- Replaced urlparse with urlsplit where appropriate. This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used). --- django/forms/fields.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django/forms/fields.py') diff --git a/django/forms/fields.py b/django/forms/fields.py index 4ec7b7aee7..1a58a60743 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -792,13 +792,13 @@ class URLField(CharField): def to_python(self, value): def split_url(url): """ - Return a list of url parts via urlparse.urlsplit(), or raise + Return a list of url parts via urlsplit(), or raise ValidationError for some malformed URLs. """ try: return list(urlsplit(url)) except ValueError: - # urlparse.urlsplit can raise a ValueError with some + # urlsplit can raise a ValueError with some # misformatted URLs. raise ValidationError(self.error_messages["invalid"], code="invalid") -- cgit v1.3