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.

Unsupported provider

classification
Title: ConfigParser: add_section('DEFAULT') causes duplicate sections.
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, draghuram, facundobatista, gvanrossum, humitos, tlesher
Priority: normal Keywords: easy, patch

Created on 2008-01-10 02:42 by tlesher, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cfgparser.diff draghuram, 2008-01-10 20:25
NEWS.diff humitos, 2008-02-23 12:29
Messages (7)
msg59652 - (view) Author: Tim Lesher (tlesher) * Date: 2008-01-10 02:42
ConfigParser doesn't prevent "manually" adding a section named DEFAULT;
however, doing so creates a duplicate, inaccessible [DEFAULT] section in
the config file:
----
>>> import sys, ConfigParser
>>> c = ConfigParser.ConfigParser()
>>> c.add_section('DEFAULT')
>>> c.write(sys.stdout)
[DEFAULT]

>>> c.set('DEFAULT', 'color', 'yellow')
>>> c.write(sys.stdout)
[DEFAULT]
color = yellow

[DEFAULT]

----
It seems that the correct thing to do would be to disallow
add_section('DEFAULT').
msg59653 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-10 03:00
Care to provide a patch?

Otherwise this may be a good bug day candidate.  The next one's Jan 19.
msg59666 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-10 16:11
It's an easy task for the bug day unless you can provide a patch and an
unit test earlier.
msg59679 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2008-01-10 20:25
Please see cfgparser.diff for the fix. It has tests and doc change.
msg59680 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2008-01-10 20:32
I should add that the patch disallows not only 'DEFAULT' but all other
variants such as "Default" and "default". I am not entirely sure if my
description of this behaviour as "DEFAULT or any of it's
case-insensitive variants".
msg62722 - (view) Author: Manuel Kaufmann (humitos) * Date: 2008-02-23 12:29
I tested the patch and works very well. I modified "Misc/NEWS" file 
beacuse the change wasn't reported and I uploaded diff file 
(NEWS.diff).
msg62724 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-02-23 12:47
Applied in r60976. Thank you all!
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46114
2008-02-23 12:47:04facundobatistasetstatus: open -> closed
nosy: + facundobatista
resolution: accepted
messages: + msg62724
2008-02-23 12:29:20humitossetfiles: + NEWS.diff
nosy: + humitos
messages: + msg62722
2008-01-15 21:01:30draghuramsetkeywords: + patch, easy
2008-01-10 20:32:45draghuramsetmessages: + msg59680
2008-01-10 20:25:26draghuramsetfiles: + cfgparser.diff
nosy: + draghuram
messages: + msg59679
2008-01-10 16:11:09christian.heimessetpriority: normal
nosy: + christian.heimes
messages: + msg59666
2008-01-10 03:00:11gvanrossumsetnosy: + gvanrossum
messages: + msg59653
2008-01-10 02:42:49tleshercreate