diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/configparser.py | 9 | ||||
-rw-r--r-- | Lib/test/test_configparser.py | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Lib/configparser.py b/Lib/configparser.py index f5666f5..de9ee53 100644 --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -525,6 +525,15 @@ class LegacyInterpolation(Interpolation): _KEYCRE = re.compile(r"%\(([^)]*)\)s|.") + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warnings.warn( + "LegacyInterpolation has been deprecated since Python 3.2 " + "and will be removed from the configparser module in Python 3.13. " + "Use BasicInterpolation or ExtendedInterpolation instead.", + DeprecationWarning, stacklevel=2 + ) + def before_get(self, parser, section, option, value, vars): rawval = value depth = MAX_INTERPOLATION_DEPTH diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py index 569959c..efd98ff 100644 --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -1666,6 +1666,14 @@ class CoverageOneHundredTestCase(unittest.TestCase): for warning in w: self.assertTrue(warning.category is DeprecationWarning) + def test_legacyinterpolation_deprecation(self): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always", DeprecationWarning) + configparser.LegacyInterpolation() + self.assertGreaterEqual(len(w), 1) + for warning in w: + self.assertIs(warning.category, DeprecationWarning) + def test_sectionproxy_repr(self): parser = configparser.ConfigParser() parser.read_string(""" |