From a5d70cca12aaa1067871eb4e67ab2ed088d1edd6 Mon Sep 17 00:00:00 2001 From: Paul Ganssle Date: Tue, 19 Jan 2021 11:16:01 +0100 Subject: [3.2.x] Refs #32365 -- Allowed use of non-pytz timezone implementations. Backport of 10d126198434810529e0220b0c6896ed64ca0e88 from master --- django/forms/utils.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'django/forms/utils.py') diff --git a/django/forms/utils.py b/django/forms/utils.py index fbe79f1142..50412f414b 100644 --- a/django/forms/utils.py +++ b/django/forms/utils.py @@ -161,6 +161,11 @@ def from_current_timezone(value): if settings.USE_TZ and value is not None and timezone.is_naive(value): current_timezone = timezone.get_current_timezone() try: + if ( + not timezone._is_pytz_zone(current_timezone) and + timezone._datetime_ambiguous_or_imaginary(value, current_timezone) + ): + raise ValueError('Ambiguous or non-existent time.') return timezone.make_aware(value, current_timezone) except Exception as exc: raise ValidationError( -- cgit v1.3