#27322: get_default_timezone() / LocalTimezone does not handle None values
-------------------------------+--------------------
     Reporter:  dmoisset       |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.10
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 When not using pytz, {{{django.utils.timezone.get_default_timezone()}}}
 returns a {{{django.utils.timezone.LocalTimezone}}} instance, which
 appears to be based in an example in the datetime documentation at
 https://docs.python.org/3.5/library/datetime.html . The examples in that
 documentation have a bug ( http://bugs.python.org/issue28386 ), which is
 related to accepting `sometz.dst(None)` method calls. That call happens
 when calling `some_time_instance.dst()`. You can reproduce with:

 {{{
 >>> from django.utils import timezone
 >>> tz = timezone.get_default_timezone()
 >>> tz
 <django.utils.timezone.LocalTimezone object at 0x7fd71280c0b8>
 >>> from datetime import time
 >>> t = time(8, 30, tzinfo=tz)
 >>> t.dst()
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/home/machinalis/0/django/lib/python3.5/site-
 packages/django/utils/timezone.py", line 112, in dst
     if self._isdst(dt):
   File "/home/machinalis/0/django/lib/python3.5/site-
 packages/django/utils/timezone.py", line 143, in _isdst
     return super(LocalTimezone, self)._isdst(dt)
   File "/home/machinalis/0/django/lib/python3.5/site-
 packages/django/utils/timezone.py", line 121, in _isdst
     tt = (dt.year, dt.month, dt.day,
 AttributeError: 'NoneType' object has no attribute 'year'
 }}}

 The example above works ok if pytz is installed (because `pytz` timezone
 classes handle None correctly)

--
Ticket URL: <https://code.djangoproject.com/ticket/27322>
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/051.5bc42fc55460da4493801cd47c5c0836%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to