Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 31465:da83f12d7a88
util: explicitly tests for None
Changeset 8b6927eb7efd 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
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 15 Mar 2017 15:07:14 -0700 |
parents | 3b7a6941a6ef |
children | afb335353d28 |
comparison
equal
deleted
inserted
replaced
31464:0e7a6279ff6e | 31465:da83f12d7a88 |
---|---|
1829 return None, s | 1829 return None, s |
1830 | 1830 |
1831 def strdate(string, format, defaults=None): | 1831 def strdate(string, format, defaults=None): |
1832 """parse a localized time string and return a (unixtime, offset) tuple. | 1832 """parse a localized time string and return a (unixtime, offset) tuple. |
1833 if the string cannot be parsed, ValueError is raised.""" | 1833 if the string cannot be parsed, ValueError is raised.""" |
1834 defaults = defaults or {} | 1834 if defaults is None: |
1835 defaults = {} | |
1835 | 1836 |
1836 # NOTE: unixtime = localunixtime + offset | 1837 # NOTE: unixtime = localunixtime + offset |
1837 offset, date = parsetimezone(string) | 1838 offset, date = parsetimezone(string) |
1838 | 1839 |
1839 # add missing elements from defaults | 1840 # add missing elements from defaults |