473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Case sensitivity bug in ConfigParser?

[Apologies if this posted twice... google groups timed out on the form
POST]

(Assume an instantiated ConfigParser, c, with a loaded file)
c.get("DEFAULT", "foo", False, {"foo": "Bar"}) 'Bar'
c.get("DEFAULT", "Foo", False, {"Foo": "Bar"}) Traceback (most recent call last):
File "<pyshell#70>", line 1, in ?
c.get("DEFAULT", "Foo", False, {"Foo": "Bar"})
File "C:\Python23\lib\ConfigParser.py", line 513, in get
raise NoOptionError(option, section)
NoOptionError: No option 'foo' in section: 'DEFAULT'
The offending code appears to be as follows (in ConfigParser.py):
def get(self, section, option):
opt = self.optionxform(option)
if section not in self._sections:
if section != DEFAULTSECT:
raise NoSectionError(section)
if opt in self._defaults:
return self._defaults[opt]
else:
raise NoOptionError(option, section)
elif opt in self._sections[section]:
return self._sections[section][opt]
elif opt in self._defaults:
return self._defaults[opt]
else:
raise NoOptionError(option, section)

It uses optionxform on the supplied option, but not on the one in the
defaults dictionary. If you're going to impose a transform then you
have to do it consistently, imho...
c.get("DEFAULT", "Foo", False, {"foo": "Bar"})

'Bar'

The supplied "Foo" gets transformed to "foo" and matches the one in
the defaults dictionary.

Seems a bit counterintuitive to expect that you supply any defaults as
pre-transformed according to your specified optionxform.

I'm not sure if this is also a problem when reading a file, but there
seems to be a related post about this (with no replies!) dating back
to 2000 http://groups.google.com/groups?hl=e...nnrp1.deja.com

I don't have time to look into it now but I'd guess this problem was
resolved in the more obvious location (when reading a file) but
patching of the defaults dictionary case was omitted.
asqui
Jul 18 '05 #1
0 2001

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg Krohn | last post by:
I'm trying to subclass ConfigParser so I can use a custom __read method (the custom format doesn't conform to RFC 822) when needed. Needless to say, it's not working as expected. In the...
0
by: asqui | last post by:
(Assume an instantiated ConfigParser, c, with a loaded file) >>> c.get("DEFAULT", "foo", False, {"foo": "Bar"}) 'Bar' >>> c.get("DEFAULT", "Foo", False, {"Foo": "Bar"}) Traceback (most recent...
32
by: Elliot Temple | last post by:
Hi I have two questions. Could someone explain to me why Python is case sensitive? I find that annoying. Also, why aren't there multiline comments? Would adding them cause a problem of some...
761
by: Neo-LISPer | last post by:
Hey Recently, I researched using C++ for game programming and here is what I found: C++ game developers spend a lot of their time debugging corrupted memory. Few, if any, compilers offer...
16
by: Starwiz | last post by:
I'm a VB.net programmer, and I'm about to start working with two C++ programmers and teach them .net. I've decided to use C# in teaching them, since it's similar enough to VB.net that I can read...
14
by: Christian Sell | last post by:
Hello, I am running into a problem with PGs case sensitivity with regard to column and table names. I am using program components that require the object names returned from database metadata...
1
by: pipehappy | last post by:
Hello everyone: I came across the module ConfigParser and can use it correctly. import ConfigParser fp = open('test.cfg','w+') config = ConfigParser.ConfigParser() config.readfp(fp)...
3
by: Anita Potekkat | last post by:
Hello, I had a question regarding Case Sensitivity in 10g & 9i. (1) Does Case Sensitivity in Oracle have to do with data only? Or does it also effect table & column names? For e.g. in a table...
2
by: sweetpotatop | last post by:
Hi, I believe my SQL server was configured as Case sensitivity. I have a number of stored procedures which were moved from a non-Case sensitivity SQL server. Because of the Case sensitivity, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.