qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qapi: Fix cgen() for Python older than 2.7


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] qapi: Fix cgen() for Python older than 2.7
Date: Mon, 7 Sep 2015 20:55:20 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 09/07/2015 09:45 AM, Markus Armbruster wrote:
> A feature new in Python 2.7 crept into commit 77e703b: re.subn()'s
> fifth argument.  Avoid that, use re.compile().
> 
> Reported-by: Laurent Desnogues <address@hidden>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  scripts/qapi.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <address@hidden>

> 
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 817d824..88fa073 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -944,7 +944,9 @@ def cgen(code, **kwds):
>      raw = code % kwds
>      if indent_level:
>          indent = genindent(indent_level)
> -        raw = re.subn("^.", indent + r'\g<0>', raw, 0, re.MULTILINE)
> +        # re.subn() lacks flags support before Python 2.7, use re.compile()
> +        raw = re.subn(re.compile("^.", re.MULTILINE),
> +                      indent + r'\g<0>', raw)
>          raw = raw[0]
>      return re.sub(re.escape(eatspace) + ' *', '', raw)
>  
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]