D2304: webcommands: unpack contents of length-1 dict portably

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sun Feb 18 05:36:16 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  ((k,v),) = dict.items() was suggested by some friends, but I feel like
  that's maybe too clever?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2304

AFFECTED FILES
  mercurial/hgweb/webcommands.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -542,7 +542,7 @@
             emptydirs = []
             h = dirs[d]
             while isinstance(h, dict) and len(h) == 1:
-                k, v = h.items()[0]
+                k, v = next(iter(h.items()))
                 if v:
                     emptydirs.append(k)
                 h = v



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list