diff --git a/python/samba/compat.py b/python/samba/compat.py index b517999defd..a2b6f3c8645 100644 --- a/python/samba/compat.py +++ b/python/samba/compat.py @@ -71,11 +71,6 @@ if PY3: # compat functions from functools import cmp_to_key as cmp_to_key_fn - # alias - def ConfigParser(defaults=None, dict_type=dict, allow_no_value=False): - from configparser import ConfigParser - return ConfigParser(defaults, dict_type, allow_no_value, interpolation=None) - else: raise NotImplementedError("Samba versions >= 4.11 do not support Python 2.x") diff --git a/python/samba/gp_parse/gp_ini.py b/python/samba/gp_parse/gp_ini.py index d567addd3ea..1fac861b0a3 100644 --- a/python/samba/gp_parse/gp_ini.py +++ b/python/samba/gp_parse/gp_ini.py @@ -22,7 +22,7 @@ import collections import re from xml.etree.ElementTree import Element, SubElement -from samba.compat import ConfigParser +from configparser import ConfigParser from io import StringIO from samba.gp_parse import GPParser, ENTITY_USER_ID @@ -34,7 +34,8 @@ class GPIniParser(GPParser): def parse(self, contents): # Required dict_type in Python 2.7 - self.ini_conf = ConfigParser(dict_type=collections.OrderedDict) + self.ini_conf = ConfigParser(dict_type=collections.OrderedDict, + interpolation=None) self.ini_conf.optionxform = str self.ini_conf.readfp(StringIO(contents.decode(self.encoding))) @@ -88,7 +89,8 @@ class GPIniParser(GPParser): def load_xml(self, root): # Required dict_type in Python 2.7 - self.ini_conf = ConfigParser(dict_type=collections.OrderedDict) + self.ini_conf = ConfigParser(dict_type=collections.OrderedDict, + interpolation=None) self.ini_conf.optionxform = str for s in root.findall('Section'): @@ -110,7 +112,8 @@ class GPTIniParser(GPIniParser): super(GPTIniParser, self).parse(contents) except UnicodeDecodeError: # Required dict_type in Python 2.7 - self.ini_conf = ConfigParser(dict_type=collections.OrderedDict) + self.ini_conf = ConfigParser(dict_type=collections.OrderedDict, + interpolation=None) self.ini_conf.optionxform = str # Fallback to Latin-1 which RSAT appears to use diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index 7f64e75d40b..37d6be38de8 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -21,7 +21,7 @@ import errno import tdb sys.path.insert(0, "bin/python") from samba import NTSTATUSError -from samba.compat import ConfigParser +from configparser import ConfigParser from io import StringIO from samba.compat import get_bytes from abc import ABCMeta, abstractmethod @@ -326,7 +326,7 @@ class gp_ext(object): class gp_inf_ext(gp_ext): def read(self, data_file): policy = open(data_file, 'rb').read() - inf_conf = ConfigParser() + inf_conf = ConfigParser(interpolation=None) inf_conf.optionxform = str try: inf_conf.readfp(StringIO(policy.decode())) @@ -525,7 +525,7 @@ def parse_gpext_conf(smb_conf): else: lp.load_default() ext_conf = lp.state_path('gpext.conf') - parser = ConfigParser() + parser = ConfigParser(interpolation=None) parser.read(ext_conf) return lp, parser