From: Joseph Sutton Date: Tue, 29 Aug 2023 04:30:08 +0000 (+1200) Subject: gp: Use read_file() instead of readfp() X-Git-Tag: tevent-0.16.0~763 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b566979acfc89ad609eb7c0c87d720f1a35f30a;p=thirdparty%2Fsamba.git gp: Use read_file() instead of readfp() readfp() is deprecated and could be removed in a future version of Python. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/gp/gpclass.py b/python/samba/gp/gpclass.py index 3b6289fe0c0..c2d612c5952 100644 --- a/python/samba/gp/gpclass.py +++ b/python/samba/gp/gpclass.py @@ -362,9 +362,9 @@ class gp_inf_ext(gp_ext): inf_conf = ConfigParser(interpolation=None) inf_conf.optionxform = str try: - inf_conf.readfp(StringIO(policy.decode())) + inf_conf.read_file(StringIO(policy.decode())) except UnicodeDecodeError: - inf_conf.readfp(StringIO(policy.decode('utf-16'))) + inf_conf.read_file(StringIO(policy.decode('utf-16'))) return inf_conf diff --git a/python/samba/gp_parse/gp_ini.py b/python/samba/gp_parse/gp_ini.py index 1fac861b0a3..342a1ee1620 100644 --- a/python/samba/gp_parse/gp_ini.py +++ b/python/samba/gp_parse/gp_ini.py @@ -38,7 +38,7 @@ class GPIniParser(GPParser): interpolation=None) self.ini_conf.optionxform = str - self.ini_conf.readfp(StringIO(contents.decode(self.encoding))) + self.ini_conf.read_file(StringIO(contents.decode(self.encoding))) def build_xml_parameter(self, section_xml, section, key_ini, val_ini): child = SubElement(section_xml, 'Parameter') @@ -117,7 +117,7 @@ class GPTIniParser(GPIniParser): self.ini_conf.optionxform = str # Fallback to Latin-1 which RSAT appears to use - self.ini_conf.readfp(StringIO(contents.decode('iso-8859-1'))) + self.ini_conf.read_file(StringIO(contents.decode('iso-8859-1'))) class GPScriptsIniParser(GPIniParser): diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 67c13b07fe5..7c2df29bdc5 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -2358,9 +2358,9 @@ PasswordComplexity Password must meet complexity requirements inf_data.optionxform=str raw = conn.loadfile(inf_file) try: - inf_data.readfp(StringIO(raw.decode())) + inf_data.read_file(StringIO(raw.decode())) except UnicodeDecodeError: - inf_data.readfp(StringIO(raw.decode('utf-16'))) + inf_data.read_file(StringIO(raw.decode('utf-16'))) except NTSTATUSError as e: if e.args[0] == NT_STATUS_ACCESS_DENIED: raise CommandError("The authenticated user does " @@ -2453,9 +2453,9 @@ samba-tool gpo manage security list {31B2F340-016D-11D2-945F-00C04FB984F9} inf_data.optionxform=str raw = conn.loadfile(inf_file) try: - inf_data.readfp(StringIO(raw.decode())) + inf_data.read_file(StringIO(raw.decode())) except UnicodeDecodeError: - inf_data.readfp(StringIO(raw.decode('utf-16'))) + inf_data.read_file(StringIO(raw.decode('utf-16'))) except NTSTATUSError as e: if e.args[0] in [NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_OBJECT_NAME_NOT_FOUND,