Title: ExtendedInterpolation drops user-defined 'vars' during _interpolate_some() recursion
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.5
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 2016-05-03 21:05 by yab-arz.

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 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.
Date User Action Args
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