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

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