[Python-bugs-list] [Bug #115362] ConfigParser chokes on capitalization

noreply@sourceforge.net noreply@sourceforge.net
Tue, 26 Sep 2000 07:04:11 -0700


Bug #115362, was updated on 2000-Sep-26 07:04
Here is a current snapshot of the bug.

Project: Python
Category: Library
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: ConfigParser chokes on capitalization

Details: Apparantly, options are meant to be case-insensitive. They are not. Line 264 of the get function transforms the requested option using "option = self.optionxform(option)". The __read function does no transformation on options it reads in.

Demonstration: The following function is a simple introspector function for a ConfigParser():

def tree_config(cfg):
	sections = cfg.sections()
	for sct in sections:
		print sct
		options = cfg.options(sct)
		for opt in options:
			try:
				value = cfg.get(sct, opt)
			except:
				value = 'Error'
			print '\t', opt, '=', value

Try it on the following config file:
[SomeSection]
X = 1
Y = 2
Z = 3

The result is:

SomeSection
	X = Error
	Z = Error
	__name__ = SomeSection
	Y = Error

Resolution:

Insert "optname = self.optionxform(optname)" before line 442 
"cursect[optname] = optval"

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=115362&group_id=5470