Patchwork [4,of,5,V2] demandimport: support keyword arguments on _hgextimport

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 9, 2015, 1:17 a.m.
Message ID <09b65b56301a659ca42d.1439083026@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/10181/
State Accepted
Headers show

Comments

Gregory Szorc - Aug. 9, 2015, 1:17 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1439078854 25200
#      Sat Aug 08 17:07:34 2015 -0700
# Node ID 09b65b56301a659ca42d470458c6c535c20b4517
# Parent  4ab009c00deee53a6125219dbba66638634a7ca5
demandimport: support keyword arguments on _hgextimport

__import__ supports keyword arguments since Python 2.5. This
proxy should too.

An upcoming patch will use this feature.

Patch

diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -42,11 +42,11 @@  level = -1
 if sys.version_info[0] >= 3:
     level = 0
 _import = _origimport
 
-def _hgextimport(importfunc, name, globals, *args):
+def _hgextimport(importfunc, name, globals, *args, **kwargs):
     try:
-        return importfunc(name, globals, *args)
+        return importfunc(name, globals, *args, **kwargs)
     except ImportError:
         if not globals:
             raise
         # extensions are loaded with "hgext_" prefix
@@ -55,9 +55,9 @@  def _hgextimport(importfunc, name, globa
         contextroot = globals.get('__name__', '').split('.', 1)[0]
         if nameroot != contextroot:
             raise
         # retry to import with "hgext_" prefix
-        return importfunc(hgextname, globals, *args)
+        return importfunc(hgextname, globals, *args, **kwargs)
 
 class _demandmod(object):
     """module demand-loader and proxy"""
     def __init__(self, name, globals, locals, level=level):