diff options
| author | Paul Ganssle <paul@ganssle.io> | 2021-01-19 11:16:01 +0100 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-01-19 12:00:40 +0100 |
| commit | a5d70cca12aaa1067871eb4e67ab2ed088d1edd6 (patch) | |
| tree | 9cee8f3ffda53629160df0fab580d8e03ae13ce7 /django/forms/utils.py | |
| parent | de4e854f079dd3a638b9919ad73e5835d5e90d3f (diff) | |
[3.2.x] Refs #32365 -- Allowed use of non-pytz timezone implementations.
Backport of 10d126198434810529e0220b0c6896ed64ca0e88 from master
Diffstat (limited to 'django/forms/utils.py')
| -rw-r--r-- | django/forms/utils.py | 5 |
1 files changed, 5 insertions, 0 deletions
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( |
