Opened 11 years ago
Closed 11 years ago
#22598 closed New feature (fixed)
make_aware throws AmbiguousTimeError exception
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Utilities | Version: | dev |
| Severity: | Normal | Keywords: | make_aware |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When using the pytz package, the make_aware() utility function occasionally throws an AmbiguousTimeError or NonExistentTimeError exception.
As the pytz maintainer explain, some dates time values may not be localizable (using the pytz.localize() function) when the optional is_dst Parameter is
None.
I don't think, that Django should throw an exception in these cases, that results in a "show stopper" behavior.
Instead, I would prefer to just "guess" it the is_dst parameter when these Exceptions occur. That may result in a 50% chance to get a 1 hour
miscalculation – but until we don't know a better way, I just prefer that instead of having some values not saved at all...
Anyway, I attached a little patch to prevent this nasty Exceptions.
Attachments (1)
Change History (4)
by , 11 years ago
| Attachment: | timezone.diff added |
|---|
comment:1 by , 11 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
% python -m this | grep ambiguity In the face of ambiguity, refuse the temptation to guess.
comment:2 by , 11 years ago
| Resolution: | wontfix |
|---|---|
| Status: | closed → new |
| Triage Stage: | Unreviewed → Ready for checkin |
| Type: | Bug → New feature |
| Version: | 1.5 → master |
patch for utils/timezone.py