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

ConfigParser.items returns items present in vars #77432

Closed
timster mannequin opened this issue Apr 9, 2018 · 8 comments
Closed

ConfigParser.items returns items present in vars #77432

timster mannequin opened this issue Apr 9, 2018 · 8 comments
Labels
3.8 only security fixes pending The issue will be closed if no feedback is provided stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@timster
Copy link
Mannequin

timster mannequin commented Apr 9, 2018

BPO 33251
Nosy @terryjreedy, @ambv, @serhiy-storchaka, @timster
PRs
  • bpo-33251: Prevent ConfigParser.items returning items present in vars. #6446
  • bpo-33251: Revert 725476222a3c1f2f93162d75a540e6bcdeaa36fd #6494
  • bpo-33251: [3.7] Revert 725476222a3c1f2f93162d75a540e6bcdeaa36fd (GH-6494) #6495
  • bpo-33251: [3.6] Revert 725476222a3c1f2f93162d75a540e6bcdeaa36fd (GH-6494) #6496
  • bpo-33333 #6567
  • bpo-33251: Update documentation to reflect change. (GH-6446) #6583
  • 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 = None
    created_at = <Date 2018-04-09.20:04:26.440>
    labels = ['3.8', 'type-bug', 'library']
    title = 'ConfigParser.items returns items present in vars'
    updated_at = <Date 2018-04-23.20:56:49.760>
    user = 'https://github.com/timster'

    bugs.python.org fields:

    activity = <Date 2018-04-23.20:56:49.760>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2018-04-09.20:04:26.440>
    creator = 'timster'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33251
    keywords = ['patch']
    message_count = 7.0
    messages = ['315148', '315374', '315375', '315390', '315628', '315673', '315679']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'lukasz.langa', 'serhiy.storchaka', 'timster']
    pr_nums = ['6446', '6494', '6495', '6496', '6567', '6583']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33251'
    versions = ['Python 3.8']

    @timster
    Copy link
    Mannequin Author

    timster mannequin commented Apr 9, 2018

    The documentation for ConfigParser.items(section, raw=False, vars=None) says the following:

    Changed in version 3.2: Items present in vars no longer appear in the result. The previous behaviour mixed actual parser options with variables provided for interpolation.

    https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.items

    However, this does not seem to be the case. The keys from vars are present in the output. Tested on 3.6.5.

    This example shows the issue:

        import configparser
    
        config = configparser.ConfigParser()
    
        config.add_section('example')
        config.set('example', 'name', 'timster %(suffix)s')
    
        data = config.items('example', vars={'suffix': 'user'})
    
        print(data)

    Expected output:

    [('name', 'timster user')]
    

    Actual output:

    [('name', 'timster user'), ('suffix', 'user')]
    

    @timster timster mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 9, 2018
    @ambv
    Copy link
    Contributor

    ambv commented Apr 17, 2018

    Hm. The documentation change was done in bpo-12036 but it seems this was actually never the case, contrary to what the conversation on that other issue there states.

    I wouldn't change it for 3.6.6 anymore since it's pretty late in the release cycle. This looks like an interesting bug fix for 3.7.

    @ambv
    Copy link
    Contributor

    ambv commented Apr 17, 2018

    Well, now that I think about it, this is not even a *bug* fix since it's behavior that configparser had since 1997.

    So that will have to go straight to 3.8.

    @ambv ambv added the 3.8 only security fixes label Apr 17, 2018
    @serhiy-storchaka
    Copy link
    Member

    What *actually* was changed in 3.2?

    @ambv
    Copy link
    Contributor

    ambv commented Apr 22, 2018

    What *actually* was changed in 3.2?

    In terms of this issue, nothing. That piece of documentation was put without proper testing, based purely on a comment that somebody put on bpo-12036. My mistake.

    @ambv
    Copy link
    Contributor

    ambv commented Apr 23, 2018

    New changeset 1d4a733 by Łukasz Langa (Chris Bradbury) in branch 'master':
    bpo-33251: Prevent ConfigParser.items returning items present in vars. (bpo-6446)
    1d4a733

    @ambv
    Copy link
    Contributor

    ambv commented Apr 23, 2018

    New changeset e500839 by Łukasz Langa (Chris Bradbury) in branch 'master':
    bpo-33251: Update documentation to reflect change. (GH-6446) (bpo-6583)
    e500839

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @furkanonder
    Copy link
    Sponsor Contributor

    @ambv The issue seems to have been resolved. Can we close the issue?

    @terryjreedy terryjreedy added the pending The issue will be closed if no feedback is provided label May 14, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes pending The issue will be closed if no feedback is provided stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants