diff --git a/tests/conf/test_parser.py b/tests/conf/test_parser.py index ad0d61e318..b192a9f354 100644 --- a/tests/conf/test_parser.py +++ b/tests/conf/test_parser.py @@ -66,3 +66,19 @@ def test_empty_option(self): conf.config_file_path = FN conf.read() self.assertEqual(conf.reposdir, '') + + def test_iterator_segfault(self): + # Verify the behavior fixed in https://bugzilla.redhat.com/show_bug.cgi?id=2330562 + empty_conf_path = tests.support.resource_path('etc/empty.conf') + + parser = ConfigParser() + parser.read(empty_conf_path) + self.assertTrue(parser.hasSection("main")) + + sectObj = parser.getData()["main"] + + # segfaulting before with Python 3.13.1 + [item for item in sectObj] + + # segfaulting before with Python 3.13.0 + [item for item in iter(sectObj)] diff --git a/tests/etc/empty.conf b/tests/etc/empty.conf new file mode 100644 index 0000000000..9280d27d75 --- /dev/null +++ b/tests/etc/empty.conf @@ -0,0 +1 @@ +[main] \ No newline at end of file