[PATCH 01 of 10] demandimport: strictly check missing locals argument

Yuya Nishihara yuya at tcha.org
Sat May 20 08:41:08 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1495260554 -32400
#      Sat May 20 15:09:14 2017 +0900
# Node ID f8ff1fc7f71f1a5956f300050014a1ebb74fdacb
# Parent  e54e0e4af63f49e42002258958698bc1fb418efb
demandimport: strictly check missing locals argument

locals may be an empty dict.

diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -158,7 +158,7 @@ class _demandmod(object):
 _pypy = '__pypy__' in sys.builtin_module_names
 
 def _demandimport(name, globals=None, locals=None, fromlist=None, level=level):
-    if not locals or name in ignore or fromlist == ('*',):
+    if locals is None or name in ignore or fromlist == ('*',):
         # these cases we can't really delay
         return _hgextimport(_import, name, globals, locals, fromlist, level)
     elif not fromlist:


More information about the Mercurial-devel mailing list