This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Daniel Moisset
Recipients Daniel Moisset, docs@python
Date 2016-10-07.16:50:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1475859032.48.0.21993169144.issue28386@psf.upfronthosting.co.za>
In-reply-to
Content
The datetime module documentation[1] describes the tzinfo.dst method with a single "dt" argument without being too explicit about possible values for it. The implication is that dt should be a datetime object, but the implementation of time.dst() [2] actually calls tz.dst(None) (where tz is an instance of some tzinfo subclass), so this should clarify that None is an allowed value.

Also, some of the examples given below in the same document (like LocalTimezone, GMT1, GMT2) actually have a related bug (it doesn't handle a None value correctly). So running

>>> ... # copy the example from the documentation
>>> t = time(tzinfo=LocalTimeZone())
>>> t.dst()

crashes with an AttributeError: 'NoneType' object has no attribute 'year'. This kind of bugs have propagated to some other projects already [2]. Some of the other examples (like USTimeZone) seem to be OK

What I think would be desirable here is:
 * A clarification on https://docs.python.org/3.5/library/datetime.html#datetime.tzinfo.dst indicating that dt is either a datetime or a None, in which situations it can be None, and what is the method supposed to return in this case.
 * Fixes in the code examples that reflect this

I would offer a patch, but I'm not quite sure of what the desired behaviour is so I wouldn't know what to document :)

[1] https://docs.python.org/3.5/library/datetime.html
[2] https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L3623
[3] https://github.com/django/django/blob/1.10.2/django/utils/timezone.py#L111
History
Date User Action Args
2016-10-07 16:50:32Daniel Moissetsetrecipients: + Daniel Moisset, docs@python
2016-10-07 16:50:32Daniel Moissetsetmessageid: <1475859032.48.0.21993169144.issue28386@psf.upfronthosting.co.za>
2016-10-07 16:50:32Daniel Moissetlinkissue28386 messages
2016-10-07 16:50:32Daniel Moissetcreate