[issue46607] Add DeprecationWarning to configparser's LegacyInterpolation

STINNER Victor report at bugs.python.org
Wed Feb 2 05:02:47 EST 2022


STINNER Victor <vstinner at python.org> added the comment:

Oh, LegacyInterpolation is not documented at:
https://docs.python.org/dev/library/configparser.html

> Other configparser deprecations were added in 3.2, but with DeprecationWarnings.

Its deprecation was never documented anywhere in Doc/.

Well, to respect the PEP 387, the class should emit a DeprecationWarning and its depreaction must be documented in What's New in Python 3.11.


> The LegacyInterpolation class of configparser has been deprecated in docs since 3.2, but without raising a DeprecationWarning.

I found the following change:
---
commit 7f64c8a5121576fd8f92010b7a936b89581c4051
Author: Łukasz Langa <lukasz at langa.pl>
Date:   Thu Dec 16 01:16:22 2010 +0000

    Broken ConfigParser removed, SafeConfigParser renamed to ConfigParser.
    Life is beatiful once again.
---

It renamed BrokenInterpolation to LegacyInterpolation:

-class BrokenInterpolation(Interpolation):
-    """Deprecated interpolation as implemented in the classic ConfigParser.
+class LegacyInterpolation(Interpolation):
+    """Deprecated interpolation used in old versions of ConfigParser.


The BrokenInterpolation class was added  by bpo-10499:
---
commit b6a6f5f886ed869612e16cd1e29a1190996dc78d
Author: Łukasz Langa <lukasz at langa.pl>
Date:   Fri Dec 3 16:28:00 2010 +0000

    Issue 10499: Modular interpolation in configparser
---

It would be nice to have Łukasz's opinion on deprecating LegacyInterpolation.


The configparser.RawConfigParser has an "interpolation" parameter and configparser.RawConfigParser._DEFAULT_INTERPOLATION is an instance of configparser.Interpolation:
---
    # Interpolation algorithm to be used if the user does not specify another        
    _DEFAULT_INTERPOLATION = Interpolation()                                       
---


If the BrokenInterpolation is removed in Python 3.13 and a project is affected by the removal, can it simply copy/paste the Python 3.12 copy in its project and continue using the class? configparser.Interpolation seems to be a clean ABC class, so it seems safe to copy/paste the code. It doesn't seem to depend on anything but configparser.Interpolation which is public (even if it's not documented).


https://bugs.python.org/issue45173#msg409685:
> Searching 4,764 sdists from the top 5,000 PyPI packages, these 13 contain "LegacyInterpolation": (...)
> two are stdlib backports: (...)
> The others are all configparser.pyi typeshed stub files: (...)

I understand that *in practice*, removing the class would impact no project of the top 5000 PyPI projects. Thanks for checking!

----------
nosy: +lukasz.langa, vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46607>
_______________________________________


More information about the Python-bugs-list mailing list