util: explicitly tests for None

Changeset 3b9cdb72931f removed the mutable default value, but did not explicitly
tested for None. Such implicit checking can introduce semantic and performance
issue. We move to an explicit check for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
This commit is contained in:
Pierre-Yves David 2017-03-15 15:07:14 -07:00
parent 8561a8e8ff
commit fc2b521909

View File

@ -1831,7 +1831,8 @@ def parsetimezone(s):
def strdate(string, format, defaults=None):
"""parse a localized time string and return a (unixtime, offset) tuple.
if the string cannot be parsed, ValueError is raised."""
defaults = defaults or {}
if defaults is None:
defaults = {}
# NOTE: unixtime = localunixtime + offset
offset, date = parsetimezone(string)