SF.net SVN: docutils:[10106 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]> Fri, 25 Apr 2025 14:30:23 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10106
          http://sourceforge.net/p/docutils/code/10106
Author:   milde
Date:     2025-04-25 14:30:22 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
Remove `frontend.ConfigParser.get_section()`.

Obsoleted by the configparser's "Mapping Protocol Access".

Modified Paths:
--------------
    trunk/docutils/RELEASE-NOTES.rst
    trunk/docutils/docutils/frontend.py

Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst	2025-04-25 14:29:41 UTC (rev 10105)
+++ trunk/docutils/RELEASE-NOTES.rst	2025-04-25 14:30:22 UTC (rev 10106)
@@ -297,6 +297,8 @@
 Removed objects
   `core.Publisher.setup_option_parser()`
      internal, obsolete,
+  `frontend.ConfigParser.get_section()`
+     obsoleted by the configparser's "Mapping Protocol Access",
   `frontend.OptionParser.set_defaults_from_dict()`
      obsolete,
   `nodes.Element.set_class()`

Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py	2025-04-25 14:29:41 UTC (rev 10105)
+++ trunk/docutils/docutils/frontend.py	2025-04-25 14:30:22 UTC (rev 10106)
@@ -1107,7 +1107,10 @@
     def handle_old_config(self, filename: str) -> None:
         warnings.warn_explicit(self.old_warning, ConfigDeprecationWarning,
                                filename, 0)
-        options = self.get_section('options')
+        try:
+            options = dict(self['options'])
+        except KeyError:
+            options = {}
         if not self.has_section('general'):
             self.add_section('general')
         for key, value in options.items():
@@ -1157,24 +1160,7 @@
         """
         return optionstr.lower().replace('-', '_')
 
-    def get_section(self, section: str) -> dict[str, str]:
-        """
-        Return a given section as a dictionary.
 
-        Return empty dictionary if the section doesn't exist.
-
-        Deprecated. Use the configparser "Mapping Protocol Access" and
-        catch KeyError.
-        """
-        warnings.warn('frontend.OptionParser.get_section() '
-                      'will be removed in Docutils 0.21 or later.',
-                      DeprecationWarning, stacklevel=2)
-        try:
-            return dict(self[section])
-        except KeyError:
-            return {}
-
-
 class ConfigDeprecationWarning(FutureWarning):
     """Warning for deprecated configuration file features."""
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.