Re: [PATCH python 13/15] generator: Fix exception catching syntax in generated code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange <berrange@xxxxxxxxxx> wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
>
> In Python3 you cannot use 'except Foo, e' you must use
> 'except Foo as e' instead, or just 'except Foo' if the
> variable isn't required.
>
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  generator.py | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/generator.py b/generator.py
> index 17f00d6..6fe810f 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -1812,10 +1812,10 @@ def qemuBuildWrappers(module):
>
>      fd.write("try:\n")
>      fd.write("    import libvirtmod_qemu\n")
> -    fd.write("except ImportError, lib_e:\n")
> +    fd.write("except ImportError as lib_e:\n")
>      fd.write("    try:\n")
>      fd.write("        import cygvirtmod_qemu as libvirtmod_qemu\n")
> -    fd.write("    except ImportError, cyg_e:\n")
> +    fd.write("    except ImportError as cyg_e:\n")
>      fd.write("        if str(cyg_e).count(\"No module named\"):\n")
>      fd.write("            raise lib_e\n\n")
>
> @@ -1923,10 +1923,10 @@ def lxcBuildWrappers(module):
>
>      fd.write("try:\n")
>      fd.write("    import libvirtmod_lxc\n")
> -    fd.write("except ImportError, lib_e:\n")
> +    fd.write("except ImportError as lib_e:\n")
>      fd.write("    try:\n")
>      fd.write("        import cygvirtmod_lxc as libvirtmod_lxc\n")
> -    fd.write("    except ImportError, cyg_e:\n")
> +    fd.write("    except ImportError as cyg_e:\n")
>      fd.write("        if str(cyg_e).count(\"No module named\"):\n")
>      fd.write("            raise lib_e\n\n")
>
> --
> 1.8.3.1
>

We'll want to use sys.exc_info() for the exceptions here so older Python compat.

-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]