From 60761e69364b23eb8816a43728a7ab0eafe5d4ed Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Apr 17 2025 14:10:53 +0000
Subject: [PATCH 1/4] revert py2 portion of mr#4214


See https://pagure.io/koji/pull-request/4214

---

diff --git a/koji/__init__.py b/koji/__init__.py
index 48cf99f..345aa3e 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -25,7 +25,6 @@
 from __future__ import absolute_import, division
 
 import base64
-import codecs
 import datetime
 import errno
 import hashlib
@@ -2343,8 +2342,7 @@ def read_config_files(config_files, raw=False):
     if six.PY3:
         config.read(cfgs, encoding="utf8")
     else:
-        for cfg in cfgs:
-            config.readfp(codecs.open(cfg, 'r', 'utf8'))
+        config.read(cfgs)
     return config
 
 

From d970eeeb5d384aaa03ee897f1f34fc7e35559d1d Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Apr 17 2025 14:10:53 +0000
Subject: [PATCH 2/4] fix unit tests


---

diff --git a/tests/test_lib/test_utils.py b/tests/test_lib/test_utils.py
index a9abf82..83215a5 100644
--- a/tests/test_lib/test_utils.py
+++ b/tests/test_lib/test_utils.py
@@ -299,8 +299,7 @@ class ConfigFileTestCase(unittest.TestCase):
                                        six.moves.configparser.ConfigParser.__class__))
         self.real_parser_clz.assert_called_once()
         if six.PY2:
-            self.real_parser_clz.return_value.read.assert_not_called()
-            self.real_parser_clz.return_value.readfp.assert_called_once()
+            self.real_parser_clz.return_value.read.assert_called_once_with([files])
         else:
             self.real_parser_clz.return_value.read.assert_called_once_with([files], encoding='utf8')
 
@@ -311,10 +310,9 @@ class ConfigFileTestCase(unittest.TestCase):
 
         self.real_parser_clz.assert_called_once()
         if six.PY2:
-            self.real_parser_clz.return_value.read.assert_not_called()
-            self.real_parser_clz.return_value.readfp.assert_called()
+            self.real_parser_clz.return_value.read.assert_called_once()
         else:
-            self.real_parser_clz.return_value.read.assert_called()
+            self.real_parser_clz.return_value.read.assert_called_once()
 
         # tuple as config_files
         self.reset_mock()
@@ -373,15 +371,13 @@ class ConfigFileTestCase(unittest.TestCase):
             conf = koji.read_config_files(files)
         listdir_mock.assert_has_calls([call('gooddir'), call('emptydir')])
         self.real_parser_clz.assert_called_once()
+        expected_files = ['test1.conf', 'gooddir/test1-1.conf', 'gooddir/test1-2.conf',
+                          'test2.conf']
         if six.PY2:
-            self.real_parser_clz.return_value.readfp.assert_called()
+            self.real_parser_clz.return_value.read.assert_called_once_with(expected_files)
         else:
-            self.real_parser_clz.return_value.read.assert_called_once_with(
-                ['test1.conf',
-                'gooddir/test1-1.conf',
-                'gooddir/test1-2.conf',
-                'test2.conf'],
-                encoding='utf8')
+            self.real_parser_clz.return_value.read.assert_called_once_with(expected_files,
+                                                                           encoding='utf8')
         self.assertEqual(self.manager.isdir.call_count, 5)
         self.assertEqual(self.manager.isfile.call_count, 6)
         self.assertEqual(self.manager.access.call_count, 4)

From 26f0e3e98a122a13a4ed73919d5eb6271e846ec5 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Apr 17 2025 14:10:53 +0000
Subject: [PATCH 3/4] drop obsolete mock


---

diff --git a/tests/test_lib/test_utils.py b/tests/test_lib/test_utils.py
index 83215a5..4e64ce1 100644
--- a/tests/test_lib/test_utils.py
+++ b/tests/test_lib/test_utils.py
@@ -247,7 +247,6 @@ class ConfigFileTestCase(unittest.TestCase):
         if six.PY2:
             self.manager.scp_clz = mock.patch("ConfigParser.SafeConfigParser",
                                               spec=True).start()
-            mock.patch('codecs.open').start()
         else:
             self.manager.cp_clz = mock.patch("configparser.ConfigParser",
                                              spec=True).start()

From 204b45edcc7cf080ec54b5deb74a1edd3828a4f7 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Apr 17 2025 14:10:53 +0000
Subject: [PATCH 4/4] fix py2 test failure


fix suggested by julian8628

---

diff --git a/tests/test_plugins/test_runroot_builder.py b/tests/test_plugins/test_runroot_builder.py
index e63af95..8924840 100644
--- a/tests/test_plugins/test_runroot_builder.py
+++ b/tests/test_plugins/test_runroot_builder.py
@@ -75,7 +75,7 @@ class FakeConfigParser(object):
         else:
             self.CONFIG = copy.deepcopy(config)
 
-    def read(self, path, encoding):
+    def read(self, path, encoding=None):
         return
 
     def sections(self):

