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.options return default opts
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, jkuan, shaleh
Priority: normal Keywords:

Created on 2001-07-14 11:11 by jkuan, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (4)
msg5399 - (view) Author: Joe Kuan (jkuan) Date: 2001-07-14 11:11
I have a config file which has the following sections

------------------
[DEFAULT]

logLevel = 9
port = 17870

[SECURITY]
user = hello

-------------------

On python, if I do the followings:

Python 2.0 (#1, Oct 16 2000, 18:10:03) 
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more
information.
>>> from ConfigParser import *
>>> f = open('/tmp/testrc', 'r')
>>> a = ConfigParser()
>>> a.defaults()
{}
>>> a.readfp(f)
>>> a.defaults()
{'port': '17870', 'loglevel': '9'}
>>> a.options("SECURITY")    
['port', 'user', 'loglevel']     <<<<<<<<!!!!!!!!!
>>> 

I thought a.options("SECURITY") will only return
['user'], however it returns everything including the
default options.

I am a bit confused.

Thanks
Joe
msg5400 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-07-19 14:36
Logged In: YES 
user_id=3066

This is an accident of the implementation; had your DEFAULT
section been named anything else (such as DEFAULT-OPTIONS),
you would not have been bitten by this.  It should not be
hard to rearrange the implementation to make the acquistion
of information from the set of default values less prone to
accidental interactions.

Assigning to myself.
msg5401 - (view) Author: Sean 'Shaleh' Perry (shaleh) Date: 2002-03-06 21:51
Logged In: YES 
user_id=37132

how do you see the implementation being changed?  Looking through the python bug list, it is not always 
clear where help is desired or able to be accepted.
msg5402 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-04-19 03:33
Logged In: YES 
user_id=3066

Based on a discussion with Guido, we think the right thing
is to avoid changing the ConfigParser module when the "bug"
can be worked around.  We need a better way to handle this
kind of configuration data, and that's on my shoulders now
(I kinda volunteered ;).

Closing this as "Won't Fix" since it doesn't appear that the
submitter had a problem with the workaround.
History
Date User Action Args
2022-04-10 16:04:12adminsetgithub: 34750
2001-07-14 11:11:21jkuancreate