]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gp: Use read_file() instead of readfp()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 29 Aug 2023 04:30:08 +0000 (16:30 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 30 Aug 2023 02:15:29 +0000 (02:15 +0000)
readfp() is deprecated and could be removed in a future version of
Python.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/gp/gpclass.py
python/samba/gp_parse/gp_ini.py
python/samba/netcmd/gpo.py

index 3b6289fe0c0234796705917fa48e6e4825630515..c2d612c59523211bde856b46a9dd85f14fb39aec 100644 (file)
@@ -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
 
 
index 1fac861b0a32f39646a9a52799f6f5cca7622336..342a1ee162061accbc5d1871f1a744bc81453dbc 100644 (file)
@@ -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):
index 67c13b07fe5c1dcf3b0a07ad0b4c944aad30bd6e..7c2df29bdc5de059b88ea6b011d68117d4d1491c 100644 (file)
@@ -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,