Blame SOURCES/scap-security-guide-0.1.58-fix_stig_overlay_python2-PR_7317.patch

76240a
From a032960b4fb8e50386fa02739b6b107b233b64ca Mon Sep 17 00:00:00 2001
76240a
From: Gabriel Becker <ggasparb@redhat.com>
76240a
Date: Mon, 2 Aug 2021 18:39:58 +0200
76240a
Subject: [PATCH] Fix a python2 issue with STIG overlay generation.
76240a
76240a
---
76240a
 utils/create-stig-overlay.py | 7 ++++++-
76240a
 1 file changed, 6 insertions(+), 1 deletion(-)
76240a
76240a
diff --git a/utils/create-stig-overlay.py b/utils/create-stig-overlay.py
76240a
index 02deb0b5b2..5d4bb835ca 100755
76240a
--- a/utils/create-stig-overlay.py
76240a
+++ b/utils/create-stig-overlay.py
76240a
@@ -107,7 +107,12 @@ def new_stig_overlay(xccdftree, ssgtree, outfile, quiet):
76240a
     lines = new_stig_overlay.findall("overlay")
76240a
     new_stig_overlay[:] = sorted(lines, key=getkey)
76240a
 
76240a
-    dom = xml.dom.minidom.parseString(ET.tostring(new_stig_overlay, encoding="UTF-8", xml_declaration=True))
76240a
+    try:
76240a
+        et_str = ET.tostring(new_stig_overlay, encoding="UTF-8", xml_declaration=True)
76240a
+    except TypeError:
76240a
+        et_str = ET.tostring(new_stig_overlay, encoding="UTF-8")
76240a
+
76240a
+    dom = xml.dom.minidom.parseString(et_str)
76240a
     pretty_xml_as_string = dom.toprettyxml(indent='  ', encoding="UTF-8")
76240a
 
76240a
     overlay_directory = os.path.dirname(outfile)