qapi: Fix cgen() for Python older than 2.7
PATCH 1/1 qapi: Fix cgen() for Python older than 2.7
A feature new in Python 2.7 crept into commit 77e703b: re.subn()'s fifth argument. Avoid that, use re.compile().
--- scripts/qapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/qapi.py +3 -1
@@ -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)
Signature · 1 line
2.4.3
Quoted 8 lines · Markus Armbruster
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 <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- scripts/qapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 17 lines
scripts/qapi.py +3
-1@@ -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)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 5 lines · Markus Armbruster
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 <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Works fine here. Thanks,
Laurent
Quoted 18 lines
--- scripts/qapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/qapi.py +3
-1@@ -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)
Peter, are you willing to commit this directly as a build fix? Or would you prefer a pull request?
Peter Maydell
AppliedQuoted 2 lines · Markus Armbruster
Peter, are you willing to commit this directly as a build fix? Or would you prefer a pull request?
Applied to master, thanks (sorry I missed this email earlier).
-- PMM
Quoted 5 lines · Markus Armbruster
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 <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Should we cc: stable on this?
thanks
-- PMM
Quoted 8 lines · Peter Maydell
Quoted 5 lines · Markus Armbruster
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 <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Should we cc: stable on this?
Not needed: commit 77e703b is not in any release, and not meant for stable.