Commit 3846d7ea authored by Łukasz Langa's avatar Łukasz Langa

Broken ConfigParser removed, SafeConfigParser renamed to ConfigParser.

Life is beatiful once again.
parent 1bd5c842
This diff is collapsed.
...@@ -5,11 +5,11 @@ and followed by "name: value" entries, with continuations and such in ...@@ -5,11 +5,11 @@ and followed by "name: value" entries, with continuations and such in
the style of RFC 822. the style of RFC 822.
Intrinsic defaults can be specified by passing them into the Intrinsic defaults can be specified by passing them into the
SafeConfigParser constructor as a dictionary. ConfigParser constructor as a dictionary.
class: class:
SafeConfigParser -- responsible for parsing a list of ConfigParser -- responsible for parsing a list of
configuration files, and managing the parsed database. configuration files, and managing the parsed database.
methods: methods:
...@@ -265,9 +265,8 @@ class InterpolationMissingOptionError(InterpolationError): ...@@ -265,9 +265,8 @@ class InterpolationMissingOptionError(InterpolationError):
class InterpolationSyntaxError(InterpolationError): class InterpolationSyntaxError(InterpolationError):
"""Raised when the source text contains invalid syntax. """Raised when the source text contains invalid syntax.
Current implementation raises this exception only for SafeConfigParser Current implementation raises this exception when the source text into
instances when the source text into which substitutions are made which substitutions are made does not conform to the required syntax.
does not conform to the required syntax.
""" """
...@@ -369,7 +368,7 @@ class Interpolation: ...@@ -369,7 +368,7 @@ class Interpolation:
class BasicInterpolation(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 option values can contain format strings which refer to other values in
the same section, or values in the special default section. the same section, or values in the special default section.
...@@ -512,8 +511,8 @@ class ExtendedInterpolation(Interpolation): ...@@ -512,8 +511,8 @@ class ExtendedInterpolation(Interpolation):
"found: %r" % (rest,)) "found: %r" % (rest,))
class BrokenInterpolation(Interpolation): class LegacyInterpolation(Interpolation):
"""Deprecated interpolation as implemented in the classic ConfigParser. """Deprecated interpolation used in old versions of ConfigParser.
Use BasicInterpolation or ExtendedInterpolation instead.""" Use BasicInterpolation or ExtendedInterpolation instead."""
_KEYCRE = re.compile(r"%\(([^)]*)\)s|.") _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
...@@ -598,12 +597,6 @@ class RawConfigParser(MutableMapping): ...@@ -598,12 +597,6 @@ class RawConfigParser(MutableMapping):
default_section=DEFAULTSECT, default_section=DEFAULTSECT,
interpolation=_UNSET): 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._dict = dict_type
self._sections = self._dict() self._sections = self._dict()
self._defaults = self._dict() self._defaults = self._dict()
...@@ -1142,8 +1135,8 @@ class RawConfigParser(MutableMapping): ...@@ -1142,8 +1135,8 @@ class RawConfigParser(MutableMapping):
- we allow valueless options but the value is not None - we allow valueless options but the value is not None
For compatibility reasons this method is not used in classic set() For compatibility reasons this method is not used in classic set()
for RawConfigParsers and ConfigParsers. It is invoked in every for RawConfigParsers. It is invoked in every case for mapping protocol
case for mapping protocol access and in SafeConfigParser.set(). access and in ConfigParser.set().
""" """
if not isinstance(section, str): if not isinstance(section, str):
raise TypeError("section names must be strings") raise TypeError("section names must be strings")
...@@ -1157,21 +1150,6 @@ class RawConfigParser(MutableMapping): ...@@ -1157,21 +1150,6 @@ class RawConfigParser(MutableMapping):
class ConfigParser(RawConfigParser): class ConfigParser(RawConfigParser):
"""ConfigParser implementing interpolation.""" """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() _DEFAULT_INTERPOLATION = BasicInterpolation()
def set(self, section, option, value=None): def set(self, section, option, value=None):
...@@ -1188,6 +1166,19 @@ class SafeConfigParser(ConfigParser): ...@@ -1188,6 +1166,19 @@ class SafeConfigParser(ConfigParser):
super().add_section(section) 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): class SectionProxy(MutableMapping):
"""A proxy for a single section from a parser.""" """A proxy for a single section from a parser."""
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment