[Spice-devel,common] codegen: Fix compatibility with Python 2.6

Submitted by Francois Gouget on July 29, 2016, 3:09 p.m.

Details

Message ID E1bT9PT-0004qT-SJ@amboise
State New
Headers show
Series "codegen: Fix compatibility with Python 2.6" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Francois Gouget July 29, 2016, 3:09 p.m.
This is needed for RHEL 6.8.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---

This is not the only patch needed to get the latest Spice server to 
compile on RHEL 6.8. But this dependency on Python 2.7 seems pretty 
needless so it may be worth applying.

 python_modules/marshal.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index 0483d3a..5445109 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -11,7 +11,7 @@  def write_includes(writer):
         src = writer.header.options["dest_file"]
     else:
         src = "generated_headers.h"
-    src = re.sub(r'[^a-z0-9]+', '_', src, flags=re.IGNORECASE)
+    src = re.sub(r'(?i)[^a-z0-9]+', '_', src, 0)
     src = src.upper()
     if src.endswith("_H"):
         src = "_H_"+src[:-2]

Comments

> 
> This is needed for RHEL 6.8.
> 
> Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
> ---
> 
> This is not the only patch needed to get the latest Spice server to
> compile on RHEL 6.8. But this dependency on Python 2.7 seems pretty
> needless so it may be worth applying.
> 

Yes, I would add in the comment that "In Python 2.6 re.sub has no flags parameter."

>  python_modules/marshal.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/python_modules/marshal.py b/python_modules/marshal.py
> index 0483d3a..5445109 100644
> --- a/python_modules/marshal.py
> +++ b/python_modules/marshal.py
> @@ -11,7 +11,7 @@ def write_includes(writer):
>          src = writer.header.options["dest_file"]
>      else:
>          src = "generated_headers.h"
> -    src = re.sub(r'[^a-z0-9]+', '_', src, flags=re.IGNORECASE)
> +    src = re.sub(r'(?i)[^a-z0-9]+', '_', src, 0)

src = re.sub(r'(?i)[^a-z0-9]+', '_', src)

works too and it's more similar (the count is the default).

>      src = src.upper()
>      if src.endswith("_H"):
>          src = "_H_"+src[:-2]

Frediano