changeset 31474: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 0e7a6279ff6e
children b6bbfbaa205a
files mercurial/util.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Wed Mar 15 15:38:02 2017 -0700
+++ b/mercurial/util.py	Wed Mar 15 15:07:14 2017 -0700
@@ -1831,7 +1831,8 @@
 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)