This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ExtendedInterpolation drops user-defined 'vars' during _interpolate_some() recursion
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: lukasz.langa Nosy List: lukasz.langa, yab-arz
Priority: normal Keywords: patch

Created on 2016-04-21 04:27 by yab-arz, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
issue26812.patch yab-arz, 2016-05-03 21:05 review
Messages (3)
msg263876 - (view) Author: Yih-En Andrew Ban (yab-arz) * Date: 2016-04-21 04:27
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'} )
msg264681 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2016-05-02 23:12
This is true. Care to author a patch?
msg264767 - (view) Author: Yih-En Andrew Ban (yab-arz) * Date: 2016-05-03 21:05
Sure, patch attached.
History
Date User Action Args
2022-04-11 14:58:29adminsetgithub: 70999
2016-05-03 21:05:46yab-arzsetfiles: + issue26812.patch
keywords: + patch
messages: + msg264767
2016-05-02 23:12:30lukasz.langasetassignee: lukasz.langa
messages: + msg264681
2016-04-21 04:27:19yab-arzcreate