Patchwork util: make strdate's defaults default value a dict

login
register
mail settings
Submitter Gregory Szorc
Date March 14, 2017, 3:51 p.m.
Message ID <e01f9adb10b291031c67.1489506700@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/19331/
State Accepted
Headers show

Comments

Gregory Szorc - March 14, 2017, 3:51 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1489506695 25200
#      Tue Mar 14 08:51:35 2017 -0700
# Node ID e01f9adb10b291031c67c887ea46f69a1cdbf797
# Parent  ed23f929af38e3249a4c0b258939e89782b20795
util: make strdate's defaults default value a dict

It was specified to be an empty list in c6adf2be6069 in 2007.
It was correct at the time. But when the function was
refactored in 91bc001a592f (2010), it started expecting a dict.
I guess this code path is untested?

Thanks to Yuya for spotting this.
Yuya Nishihara - March 15, 2017, 1:08 p.m.
On Tue, 14 Mar 2017 08:51:40 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1489506695 25200
> #      Tue Mar 14 08:51:35 2017 -0700
> # Node ID e01f9adb10b291031c67c887ea46f69a1cdbf797
> # Parent  ed23f929af38e3249a4c0b258939e89782b20795
> util: make strdate's defaults default value a dict

Queued, thanks.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1830,7 +1830,7 @@  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 []
+    defaults = defaults or {}
 
     # NOTE: unixtime = localunixtime + offset
     offset, date = parsetimezone(string)