Patchwork [4,of,8] demandimport: pass fromlist to original import function

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 23, 2015, 6:24 a.m.
Message ID <030387dc5db0113c41a0.1450851882@bryano-mbp.local>
Download mbox | patch
Permalink /patch/12268/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Bryan O'Sullivan - Dec. 23, 2015, 6:24 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 1450849086 28800
#      Tue Dec 22 21:38:06 2015 -0800
# Node ID 030387dc5db0113c41a0b3b4ba72a118aa2bc84b
# Parent  84a069c3cf4bfcc56cd889a7c03ef974d3913b98
demandimport: pass fromlist to original import function

Without this, nested imports of the variety "from . import wibble" break.
But that bug is in turn hidden by the "if" clause immediately before,
which we will excise in the next commit.
Yuya Nishihara - Dec. 23, 2015, 1:09 p.m.
On Tue, 22 Dec 2015 22:24:42 -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bos@serpentine.com>
> # Date 1450849086 28800
> #      Tue Dec 22 21:38:06 2015 -0800
> # Node ID 030387dc5db0113c41a0b3b4ba72a118aa2bc84b
> # Parent  84a069c3cf4bfcc56cd889a7c03ef974d3913b98
> demandimport: pass fromlist to original import function
> 
> Without this, nested imports of the variety "from . import wibble" break.
> But that bug is in turn hidden by the "if" clause immediately before,
> which we will excise in the next commit.
> 
> diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
> --- a/mercurial/demandimport.py
> +++ b/mercurial/demandimport.py
> @@ -191,7 +191,8 @@ def _demandimport(name, globals=None, lo
>                  return _hgextimport(_origimport, name, globals, locals,
>                                      fromlist, level)
>  
> -            mod = _hgextimport(_origimport, name, globals, locals, level=level)
> +            mod = _hgextimport(_origimport, name, globals, locals, fromlist,
> +                               level)
>  
>              for x in fromlist:
>                  processfromitem(mod, x)

Doesn't it disable lazy loading of modules in fromlist?

Patch

diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -191,7 +191,8 @@  def _demandimport(name, globals=None, lo
                 return _hgextimport(_origimport, name, globals, locals,
                                     fromlist, level)
 
-            mod = _hgextimport(_origimport, name, globals, locals, level=level)
+            mod = _hgextimport(_origimport, name, globals, locals, fromlist,
+                               level)
 
             for x in fromlist:
                 processfromitem(mod, x)