summaryrefslogtreecommitdiffstats
path: root/Lib/configparser.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2022-06-21 21:31:25 (GMT)
committerGitHub <noreply@github.com>2022-06-21 21:31:25 (GMT)
commit296e4efebbd1865153ed3be24887a2af3898a0c4 (patch)
tree8a9fc16d932023ce8eec314984d89a552d295630 /Lib/configparser.py
parent4abab6b603dd38bec1168e9a37c40a48ec89508e (diff)
downloadcpython-296e4efebbd1865153ed3be24887a2af3898a0c4.zip
cpython-296e4efebbd1865153ed3be24887a2af3898a0c4.tar.gz
cpython-296e4efebbd1865153ed3be24887a2af3898a0c4.tar.bz2
gh-89336: Remove configparser APIs that were deprecated for 3.12 (#92503)
https://github.com/python/cpython/issue/89336: Remove configparser 3.12 deprecations. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/configparser.py')
-rw-r--r--Lib/configparser.py61
1 files changed, 5 insertions, 56 deletions
diff --git a/Lib/configparser.py b/Lib/configparser.py
index de9ee53..f98e6fb 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -148,14 +148,14 @@ import re
import sys
import warnings
-__all__ = ["NoSectionError", "DuplicateOptionError", "DuplicateSectionError",
+__all__ = ("NoSectionError", "DuplicateOptionError", "DuplicateSectionError",
"NoOptionError", "InterpolationError", "InterpolationDepthError",
"InterpolationMissingOptionError", "InterpolationSyntaxError",
"ParsingError", "MissingSectionHeaderError",
- "ConfigParser", "SafeConfigParser", "RawConfigParser",
+ "ConfigParser", "RawConfigParser",
"Interpolation", "BasicInterpolation", "ExtendedInterpolation",
"LegacyInterpolation", "SectionProxy", "ConverterMapping",
- "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"]
+ "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH")
_default_dict = dict
DEFAULTSECT = "DEFAULT"
@@ -297,41 +297,12 @@ class InterpolationDepthError(InterpolationError):
class ParsingError(Error):
"""Raised when a configuration file does not follow legal syntax."""
- def __init__(self, source=None, filename=None):
- # Exactly one of `source'/`filename' arguments has to be given.
- # `filename' kept for compatibility.
- if filename and source:
- raise ValueError("Cannot specify both `filename' and `source'. "
- "Use `source'.")
- elif not filename and not source:
- raise ValueError("Required argument `source' not given.")
- elif filename:
- source = filename
- Error.__init__(self, 'Source contains parsing errors: %r' % source)
+ def __init__(self, source):
+ super().__init__(f'Source contains parsing errors: {source!r}')
self.source = source
self.errors = []
self.args = (source, )
- @property
- def filename(self):
- """Deprecated, use `source'."""
- warnings.warn(
- "The 'filename' attribute will be removed in Python 3.12. "
- "Use 'source' instead.",
- DeprecationWarning, stacklevel=2
- )
- return self.source
-
- @filename.setter
- def filename(self, value):
- """Deprecated, user `source'."""
- warnings.warn(
- "The 'filename' attribute will be removed in Python 3.12. "
- "Use 'source' instead.",
- DeprecationWarning, stacklevel=2
- )
- self.source = value
-
def append(self, lineno, line):
self.errors.append((lineno, line))
self.message += '\n\t[line %2d]: %s' % (lineno, line)
@@ -768,15 +739,6 @@ class RawConfigParser(MutableMapping):
elements_added.add((section, key))
self.set(section, key, value)
- def readfp(self, fp, filename=None):
- """Deprecated, use read_file instead."""
- warnings.warn(
- "This method will be removed in Python 3.12. "
- "Use 'parser.read_file()' instead.",
- DeprecationWarning, stacklevel=2
- )
- self.read_file(fp, source=filename)
-
def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
"""Get an option value for a given section.
@@ -1239,19 +1201,6 @@ class ConfigParser(RawConfigParser):
self._interpolation = hold_interpolation
-class SafeConfigParser(ConfigParser):
- """ConfigParser alias for backwards compatibility purposes."""
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- warnings.warn(
- "The SafeConfigParser class has been renamed to ConfigParser "
- "in Python 3.2. This alias will be removed in Python 3.12."
- " Use ConfigParser directly instead.",
- DeprecationWarning, stacklevel=2
- )
-
-
class SectionProxy(MutableMapping):
"""A proxy for a single section from a parser."""