Skip to content

ExtendedInterpolation drops user-defined 'vars' during _interpolate_some() recursion #70999

Description

@yab-arz
mannequin
BPO 26812
Nosy @ambv, @yab-arz
Files
  • issue26812.patch
  • 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 = 'https://github.com/ambv'
    closed_at = None
    created_at = <Date 2016-04-21.04:27:19.348>
    labels = ['type-bug', 'library']
    title = "ExtendedInterpolation drops user-defined 'vars' during _interpolate_some() recursion"
    updated_at = <Date 2016-05-03.21:05:46.459>
    user = 'https://github.com/yab-arz'

    bugs.python.org fields:

    activity = <Date 2016-05-03.21:05:46.459>
    actor = 'yab-arz'
    assignee = 'lukasz.langa'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2016-04-21.04:27:19.348>
    creator = 'yab-arz'
    dependencies = []
    files = ['42702']
    hgrepos = []
    issue_num = 26812
    keywords = ['patch']
    message_count = 3.0
    messages = ['263876', '264681', '264767']
    nosy_count = 2.0
    nosy_names = ['lukasz.langa', 'yab-arz']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26812'
    versions = ['Python 3.5']

    Linked PRs

    Activity

    1. yab-arz commented on Apr 21, 2016

      yab-arzmannequin
      MannequinAuthor

      In Python 3.5.1, configparser.ExtendedInterpolation will drop the user-defined 'vars' passed in via ConfigParser.get(vars=...) due to a bug when recursing beyond depth 1 in ExtendedInterpolation._interpolate_some(). Line 509 of configparser.py currently reads: 'dict(parser.items(sect, raw=True))' This appears to be a mistake and should instead be: 'map', which includes the user-defined vars.

      The following code will trigger an InterpolationMissingOptionError without the fix, and runs as expected with the fix:

      from configparser import *
      parser = ConfigParser( interpolation=ExtendedInterpolation() )
      parser.add_section( 'Section' )
      parser.set( 'Section', 'first', '${userdef}' )
      parser.set( 'Section', 'second', '${first}' )
      parser[ 'Section' ].get( 'second', vars={'userdef': 'userval'} )
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Apr 21, 2016
    3. ambv commented on May 2, 2016

      @ambv
      Contributor

      This is true. Care to author a patch?

    4. self-assigned this
      on May 2, 2016
    5. yab-arz commented on May 3, 2016

      yab-arzmannequin
      MannequinAuthor

      Sure, patch attached.

    6. transferred this issue fromon Apr 10, 2022
    7. added 3 commits that reference this issue on Aug 16, 2026
    8. added a commit that references this issue on Sep 2, 2026
    9. added 2 commits that reference this issue on Sep 29, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions