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

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