#27138: timezone.localtime accepts naive datetimes on Python ≥ 3.6
-----------------------------------------+------------------------
Reporter: aaugustin | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
`timezone.localtime` is documented not to accept naive datetimes, however,
it does on Python ≥ 3.6, cf. a7a7ecd2b026c61a39a46d2d7eced0e06a92c970.
For the sake of consistency across Python versions, I think it would be
best to implement one of the following two options:
1. maintain the current API, check for naive datetimes and raise an
exception,
2. accept naive datetimes, convert them to aware datetimes with a warning
(like Django does in other places) and update the documentation
accordingly.
See https://github.com/django/django/pull/7134#issuecomment-241388846 for
a longer discussion of option 2.
--
Ticket URL: <https://code.djangoproject.com/ticket/27138>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.a754de7b8de535e8c576995b82d88370%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.