New submission from Patrick Westerhoff:
I’ve noticed that the methods in `datetime.timezone` all require a datetime
object (or explicitely `None`) as its parameter or they will raise an exception.
The datetime object however is never required for the implementation of the
method, so it seems to me like an unnecessary requirement, given that timezone
objects are completely independent of datetime objects.
For example `timezone.utcoffset` is implemented like this:
def utcoffset(self, dt):
if isinstance(dt, datetime) or dt is None:
return self._offset
raise TypeError("utcoffset() argument must be a datetime instance"
" or None")
I don’t really understand this requirement and if there isn’t an actual reason
for it (if there is, it should be documented somewhere), I’d suggest to remove
this requirement completely. For backwards compatibility, the parameter could
simply default to `None`.
----------
components: Library (Lib)
messages: 225188
nosy: poke
priority: normal
severity: normal
status: open
title: datetime.timezone methods require datetime object
type: behavior
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com