d58195b
From 0125a130fb3352ecd435b3f9f8e880a4f60a5c4c Mon Sep 17 00:00:00 2001
d58195b
From: Lukas Atkinson <amon@cpan.org>
d58195b
Date: Fri, 30 Dec 2016 00:39:19 +0100
d58195b
Subject: [PATCH] re-enable HTML reports under Python3
d58195b
d58195b
In commit 1cc987a23, the `commonpath()` function was added, which quite
d58195b
sensibly tries to figure out real path names. Unfortunately, it uses
d58195b
`iterools.izip()` which is not available under Python3. Instead, that
d58195b
functionality is now provided by the `zip()` builtin.
d58195b
d58195b
We therefore define an `izip()` function as an alias for
d58195b
`itertools.izip()` if that is available, or else use `zip()`.
d58195b
d58195b
Since `commonpath()` is used in HTML reports, it was previously
d58195b
impossible to create HTML reports with GCOVR under Python3.
d58195b
To prevent such problems in the future, the existing HTML tests should
d58195b
be updated and enabled.
d58195b
---
d58195b
 scripts/gcovr | 8 +++++++-
d58195b
 1 file changed, 7 insertions(+), 1 deletion(-)
d58195b
d58195b
diff --git a/scripts/gcovr b/scripts/gcovr
d58195b
index a7b733e..000d0b7 100755
d58195b
--- a/scripts/gcovr
d58195b
+++ b/scripts/gcovr
d58195b
@@ -55,6 +55,12 @@ try:
d58195b
 except NameError:
d58195b
     xrange = range
d58195b
 
d58195b
+# In Python3, zip is equivalent to izip
d58195b
+try:
d58195b
+    izip = itertools.izip
d58195b
+except AttributeError:
d58195b
+    izip = zip
d58195b
+
d58195b
 medium_coverage = 75.0
d58195b
 high_coverage = 90.0
d58195b
 low_color = "LightPink"
d58195b
@@ -410,7 +416,7 @@ def commonpath( files ):
d58195b
         path = os.path.realpath(f)
d58195b
         dirs = path.split( os.path.sep )
d58195b
         common = []
d58195b
-        for a, b in itertools.izip( dirs, common_dirs ):
d58195b
+        for a, b in izip( dirs, common_dirs ):
d58195b
             if a == b:
d58195b
                 common.append( a )
d58195b
             elif common: