From: Noel Power Date: Mon, 15 Oct 2018 09:58:23 +0000 (+0100) Subject: python/samba/gp_parse: PY2/PY3 compat porting for gp_init.py X-Git-Tag: tdb-1.3.17~1246 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04c118cf0eefebe5e25cdd687c0d970c7ba70b67;p=thirdparty%2Fsamba.git python/samba/gp_parse: PY2/PY3 compat porting for gp_init.py 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 Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/gp_parse/gp_ini.py b/python/samba/gp_parse/gp_ini.py index 196175e1651..58aee88a1e1 100644 --- a/python/samba/gp_parse/gp_ini.py +++ b/python/samba/gp_parse/gp_ini.py @@ -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():