[ python-Bugs-997050 ] ConfigParser behavior change
SourceForge.net
noreply at sourceforge.net
Tue Aug 24 17:04:14 CEST 2004
Bugs item #997050, was opened at 2004-07-24 08:30
Message generated for change (Comment added) made by goodger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=997050&group_id=5470
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: David Goodger (goodger)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: ConfigParser behavior change
Initial Comment:
ConfigParser.set() doesn't allow non-string arguments
for 'value' any
more. This breaks Docutils code. I submit that the
behavior should
not have been changed, rather that the documentation
needed updating.
I volunteer to undo the change and update the
documentation.
ConfigParser.py rev. 1.65 implements the fix detailed
in bug report
810843 (http://python.org/sf/810843):
Fixed using methods (2) and (3): ConfigParser.set()
now checks
that the value is some flavor of string, and raises
TypeError if
it isn't. This is documented behavior; regression
tests have been
added.
"This is documented behavior": where was this behavior
documented
before the bug fix? I couldn't find it. If it wasn't
documented,
wouldn't method 4 (from the bug report, below) have
been more
appropriate?
(4) Stating in the documentation that the raw parameter
should be used when an option's value might not be of
type string (this might be the intended usage, but it
isn't made clear).
IOW, perhaps it wasn't a code bug but rather an
omission in the docs.
By adding the restriction and raising TypeError, it
breaks Docutils,
which subclasses ConfigParser. If the string-only
restriction *was*
documented and I just missed it, I'll accept that the
Docutils code
was at fault (it's not the first time ;-) and rework
it. But if that
restriction wasn't documented, I don't think
ConfigParser's behavior
should change.
See also
<http://article.gmane.org/gmane.text.docutils.devel/2073>.
----------------------------------------------------------------------
>Comment By: David Goodger (goodger)
Date: 2004-08-24 11:04
Message:
Logged In: YES
user_id=7733
The alternative is the following change in Docutils.
Unfortunately, it requires access to internal implementation
details marked with single leading underscores.
diff -u -r1.64 frontend.py
--- docutils/frontend.py 24 Jul 2004 14:13:38 -0000 1.64
+++ docutils/frontend.py 24 Aug 2004 15:01:32 -0000
@@ -637,6 +637,22 @@
section_dict[option] = self.get(section,
option, raw=1)
return section_dict
+ def set(self, section, option, value):
+ """
+ Set an option.
+
+ Overrides stdlib ConfigParser's set() method to
allow non-string
+ values. Required for compatibility with Python 2.4.
+ """
+ if not section or section == CP.DEFAULTSECT:
+ sectdict = self._defaults
+ else:
+ try:
+ sectdict = self._sections[section]
+ except KeyError:
+ raise CP.NoSectionError(section)
+ sectdict[self.optionxform(option)] = value
+
class ConfigDeprecationWarning(DeprecationWarning):
"""Warning for deprecated configuration file features."""
----------------------------------------------------------------------
Comment By: David Goodger (goodger)
Date: 2004-08-24 11:00
Message:
Logged In: YES
user_id=7733
The change that I'm proposing to revert:
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/ConfigParser.py?r1=1.64&r2=1.65
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=997050&group_id=5470
More information about the Python-bugs-list
mailing list