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

login
register
mail settings
Submitter phabricator
Date Feb. 18, 2018, 5:36 a.m.
Message ID <differential-rev-PHID-DREV-o35bkckuo76oh2fbiuwx-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28043/
State Superseded
Headers show

Comments

phabricator - Feb. 18, 2018, 5:36 a.m.
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




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

Patch

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