Patchwork [2/4] tracetool: use Python 2.4-compatible __import__() arguments

login
register
mail settings
Submitter Stefan Hajnoczi
Date April 27, 2012, 2:23 p.m.
Message ID <1335536625-4621-3-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/155484/
State New
Headers show

Comments

Stefan Hajnoczi - April 27, 2012, 2:23 p.m.
In Python 2.5 keyword arguments were added to __import__().  Avoid using
them to achieve Python 2.4 compatibility.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 scripts/tracetool/__init__.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Lluís Vilanova - April 27, 2012, 5:32 p.m.
Stefan Hajnoczi writes:

> In Python 2.5 keyword arguments were added to __import__().  Avoid using
> them to achieve Python 2.4 compatibility.

> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Reviewed-by: Lluís Vilanova <vilanova@ac.upc.edu>

> ---
>  scripts/tracetool/__init__.py |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> index 74fe21b..49858c9 100644
> --- a/scripts/tracetool/__init__.py
> +++ b/scripts/tracetool/__init__.py
> @@ -204,7 +204,7 @@ def try_import(mod_name, attr_name = None, attr_default = None):
>      object or attribute value.
>      """
>      try:
> -        module = __import__(mod_name, fromlist=["__package__"])
> +        module = __import__(mod_name, globals(), locals(), ["__package__"])
>          if attr_name is None:
>              return True, module
>          return True, getattr(module, str(attr_name), attr_default)
> -- 
> 1.7.10

Patch

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 74fe21b..49858c9 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -204,7 +204,7 @@  def try_import(mod_name, attr_name = None, attr_default = None):
     object or attribute value.
     """
     try:
-        module = __import__(mod_name, fromlist=["__package__"])
+        module = __import__(mod_name, globals(), locals(), ["__package__"])
         if attr_name is None:
             return True, module
         return True, getattr(module, str(attr_name), attr_default)