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: ConfigParser: fixes mixed-case interpolations (bug 857881)
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, jrm
Priority: normal Keywords: patch

Created on 2003-12-24 17:25 by jrm, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ConfigParser.patch jrm, 2003-12-24 17:25 ConfigParser.py context diff
Messages (2)
msg45071 - (view) Author: Jordan R McCoy (jrm) Date: 2003-12-24 17:25
(Python CVS on FreeBSD 4.7 release)

ConfigParser translates option names into full lowercase 
before associating them with the section dictionary (in 
function RawConfigParser->optionxform, used multiple 
locations); this seems to indicate that option names 
should be interpreted in a case-insensitive manner.

However, the interpolation function in ConfigParser 
(_interpolate), uses the standard % string substitution 
construct, which is of course case-sensitive...thus,  
interpolations like '%(logFilename)' generate an 
exception. (See bug report 857881 for test case.)

This patch translates interpolations to full lowercase 
using a regular expression substitution before they are 
interpolated.

Since interpolations may run multiple times depending on 
their depth, this isn't the optimal solution, but is 
probably faster then the tokenizer interpolation used by 
SafeConfigParser. 
msg45072 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004-05-18 02:27
Logged In: YES 
user_id=3066

The attached patch does not properly solve the problem.  In
particular:
- it uses str.lower() instead of self.optionxform() to
convert the string
- it does not fix SafeConfigParser

I'm committing a similar patch that makes these changes so
it works properly, and have modified the tests to rely on
this fix (and so test that it doesn't regress).  I've added
a bit to the documentation to explain this as well.

Doc/lib/libcfgparser.tex 1.35
Lib/ConfigParser.py 1.64
Lib/test/test_cfgparser.py 1.21
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39732
2003-12-24 17:25:39jrmcreate