summaryrefslogtreecommitdiffstats
path: root/Lib/configparser.py
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2010-12-16 01:16:22 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2010-12-16 01:16:22 (GMT)
commit7f64c8a5121576fd8f92010b7a936b89581c4051 (patch)
tree9052d6bc0ef45cedd2d73b5be4f53a0f5d1f472a /Lib/configparser.py
parentbb9686f66fb517b16324958cbb3ba9f1b52b45c6 (diff)
downloadcpython-7f64c8a5121576fd8f92010b7a936b89581c4051.zip
cpython-7f64c8a5121576fd8f92010b7a936b89581c4051.tar.gz
cpython-7f64c8a5121576fd8f92010b7a936b89581c4051.tar.bz2
Broken ConfigParser removed, SafeConfigParser renamed to ConfigParser.
Life is beatiful once again.
Diffstat (limited to 'Lib/configparser.py')
-rw-r--r--Lib/configparser.py53
1 files changed, 22 insertions, 31 deletions
diff --git a/Lib/configparser.py b/Lib/configparser.py
index b5623cd..aba444c 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -5,11 +5,11 @@ and followed by "name: value" entries, with continuations and such in
the style of RFC 822.
Intrinsic defaults can be specified by passing them into the
-SafeConfigParser constructor as a dictionary.
+ConfigParser constructor as a dictionary.
class:
-SafeConfigParser -- responsible for parsing a list of
+ConfigParser -- responsible for parsing a list of
configuration files, and managing the parsed database.
methods:
@@ -265,9 +265,8 @@ class InterpolationMissingOptionError(InterpolationError):
class InterpolationSyntaxError(InterpolationError):
"""Raised when the source text contains invalid syntax.
- Current implementation raises this exception only for SafeConfigParser
- instances when the source text into which substitutions are made
- does not conform to the required syntax.
+ Current implementation raises this exception when the source text into
+ which substitutions are made does not conform to the required syntax.
"""
@@ -369,7 +368,7 @@ class Interpolation:
class BasicInterpolation(Interpolation):
- """Interpolation as implemented in the classic SafeConfigParser.
+ """Interpolation as implemented in the classic ConfigParser.
The option values can contain format strings which refer to other values in
the same section, or values in the special default section.
@@ -512,8 +511,8 @@ class ExtendedInterpolation(Interpolation):
"found: %r" % (rest,))
-class BrokenInterpolation(Interpolation):
- """Deprecated interpolation as implemented in the classic ConfigParser.
+class LegacyInterpolation(Interpolation):
+ """Deprecated interpolation used in old versions of ConfigParser.
Use BasicInterpolation or ExtendedInterpolation instead."""
_KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
@@ -598,12 +597,6 @@ class RawConfigParser(MutableMapping):
default_section=DEFAULTSECT,
interpolation=_UNSET):
- if self.__class__ is RawConfigParser:
- warnings.warn(
- "The RawConfigParser class will be removed in future versions."
- " Use 'SafeConfigParser(interpolation=None)' instead.",
- DeprecationWarning, stacklevel=2
- )
self._dict = dict_type
self._sections = self._dict()
self._defaults = self._dict()
@@ -1142,8 +1135,8 @@ class RawConfigParser(MutableMapping):
- we allow valueless options but the value is not None
For compatibility reasons this method is not used in classic set()
- for RawConfigParsers and ConfigParsers. It is invoked in every
- case for mapping protocol access and in SafeConfigParser.set().
+ for RawConfigParsers. It is invoked in every case for mapping protocol
+ access and in ConfigParser.set().
"""
if not isinstance(section, str):
raise TypeError("section names must be strings")
@@ -1157,21 +1150,6 @@ class RawConfigParser(MutableMapping):
class ConfigParser(RawConfigParser):
"""ConfigParser implementing interpolation."""
- _DEFAULT_INTERPOLATION = BrokenInterpolation()
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- if self.__class__ is ConfigParser:
- warnings.warn(
- "The ConfigParser class will be removed in future versions."
- " Use SafeConfigParser instead.",
- DeprecationWarning, stacklevel=2
- )
-
-
-class SafeConfigParser(ConfigParser):
- """ConfigParser implementing sane interpolation."""
-
_DEFAULT_INTERPOLATION = BasicInterpolation()
def set(self, section, option, value=None):
@@ -1188,6 +1166,19 @@ class SafeConfigParser(ConfigParser):
super().add_section(section)
+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 future versions."
+ " Use ConfigParser directly instead.",
+ DeprecationWarning, stacklevel=2
+ )
+
+
class SectionProxy(MutableMapping):
"""A proxy for a single section from a parser."""