Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DeprecationWarning to configparser's LegacyInterpolation #90765

Closed
hugovk opened this issue Feb 2, 2022 · 5 comments
Closed

Add DeprecationWarning to configparser's LegacyInterpolation #90765

hugovk opened this issue Feb 2, 2022 · 5 comments
Labels
3.11 stdlib Python modules in the Lib dir

Comments

@hugovk
Copy link
Member

hugovk commented Feb 2, 2022

BPO 46607
Nosy @gpshead, @vstinner, @ambv, @hugovk
PRs
  • bpo-46607: Add DeprecationWarning to LegacyInterpolation #30927
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-04-05.22:08:56.439>
    created_at = <Date 2022-02-02.07:01:09.212>
    labels = ['library', '3.11']
    title = "Add DeprecationWarning to configparser's LegacyInterpolation"
    updated_at = <Date 2022-04-05.22:08:56.438>
    user = 'https://github.com/hugovk'

    bugs.python.org fields:

    activity = <Date 2022-04-05.22:08:56.438>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-04-05.22:08:56.439>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2022-02-02.07:01:09.212>
    creator = 'hugovk'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46607
    keywords = ['patch']
    message_count = 5.0
    messages = ['412339', '412347', '412391', '416785', '416822']
    nosy_count = 4.0
    nosy_names = ['gregory.p.smith', 'vstinner', 'lukasz.langa', 'hugovk']
    pr_nums = ['30927']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46607'
    versions = ['Python 3.11']

    @hugovk
    Copy link
    Member Author

    hugovk commented Feb 2, 2022

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

    The 3.2 HISTORY file says:

    • configparser: the SafeConfigParser class has been renamed to ConfigParser.
      The legacy ConfigParser class has been removed but its interpolation mechanism is still available as LegacyInterpolation.

    Searching the top 5,000 PyPI sdists, there's very little (if any "real") use of LegacyInterpolation. Details: https://bugs.python.org/issue45173#msg409685

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

    Let's add a DeprecationWarning for a couple of releases before removal.

    @hugovk hugovk added 3.11 stdlib Python modules in the Lib dir labels Feb 2, 2022
    @vstinner
    Copy link
    Member

    vstinner commented Feb 2, 2022

    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 7f64c8a
    Author: Łukasz Langa <lukasz@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 b6a6f5f
    Author: Łukasz Langa <lukasz@langa.pl>
    Date: Fri Dec 3 16:28:00 2010 +0000

    bpo-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!

    @hugovk
    Copy link
    Member Author

    hugovk commented Feb 2, 2022

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

    Its deprecation was never documented anywhere in Doc/.

    Correct, only in the docstring:

    class LegacyInterpolation(Interpolation):
        """Deprecated interpolation used in old versions of ConfigParser.
        Use BasicInterpolation or ExtendedInterpolation instead."""
    

    I've updated #75110 to say "deprecated in the docstring" instead of "deprecated in docs".

    @gpshead
    Copy link
    Member

    gpshead commented Apr 5, 2022

    New changeset 7528094 by Hugo van Kemenade in branch 'main':
    bpo-46607: Add DeprecationWarning for LegacyInterpolation, deprecated in docs since 3.2 (GH-30927)
    7528094

    @vstinner
    Copy link
    Member

    vstinner commented Apr 5, 2022

    Thanks Hugo for the your contribution. I close the issue.

    Searching the top 5,000 PyPI sdists, there's very little (if any "real") use of LegacyInterpolation. Details: https://bugs.python.org/issue45173#msg409685

    You can offer them a PR to avoid the deprecated API, or at least notify them by creating an issue that this API is deprecated in Python 3.11.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants