]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python/samba/gp_parse: PY2/PY3 compat porting for gp_init.py
authorNoel Power <noel.power@suse.com>
Mon, 15 Oct 2018 09:58:23 +0000 (10:58 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 23 Oct 2018 03:50:26 +0000 (05:50 +0200)
Fixes
1) use compat versions of ConfigParser and StringIO
2) open file needs to be opened in binary mode as write_pretty_xml
   routine uses BytesIO() object.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/gp_parse/gp_ini.py

index 196175e16518b7de1bf7db113f5eb30754be611d..58aee88a1e1de3add1a73d7c7e4fc25eb6037dbc 100644 (file)
@@ -21,9 +21,9 @@ import codecs
 import collections
 import re
 
-from ConfigParser import ConfigParser
 from xml.etree.ElementTree import Element, SubElement
-from StringIO import StringIO
+from samba.compat import ConfigParser
+from samba.compat import StringIO
 
 from samba.gp_parse import GPParser, ENTITY_USER_ID
 
@@ -70,7 +70,7 @@ class GPIniParser(GPParser):
         return section_name
 
     def write_xml(self, filename):
-        with file(filename, 'w') as f:
+        with open(filename, 'wb') as f:
             root = Element('IniFile')
 
             for sec_ini in self.ini_conf.sections():