summaryrefslogtreecommitdiff
path: root/Doc/library/configparser.rst
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2010-12-04 12:46:01 +0000
committerŁukasz Langa <lukasz@langa.pl>2010-12-04 12:46:01 +0000
commita934a0edb430b2c53656ab4611b327ed74180169 (patch)
tree00bbe1235c56eab99245ce804f0ae0cc820df125 /Doc/library/configparser.rst
parent4207299c7b6b530a8d389580020998770573c363 (diff)
downloadcpython-a934a0edb430b2c53656ab4611b327ed74180169.tar.gz
configparser: fixed inconsistency where in SafeConfigParser option values
were ensured to be strings but section names and option keys were not. Behaviour unchanged for RawConfigParser and ConfigParser.
Diffstat (limited to 'Doc/library/configparser.rst')
-rw-r--r--Doc/library/configparser.rst22
1 files changed, 18 insertions, 4 deletions
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 6822176093..154d062590 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -836,7 +836,11 @@ SafeConfigParser Objects
Add a section named *section* to the instance. If a section by the given
name already exists, :exc:`DuplicateSectionError` is raised. If the
- *default section* name is passed, :exc:`ValueError` is raised.
+ *default section* name is passed, :exc:`ValueError` is raised. The name
+ of the section must be a string; if not, :exc:`TypeError` is raised.
+
+ .. versionchanged:: 3.2
+ Non-string section names raise :exc:`TypeError`.
.. method:: has_section(section)
@@ -976,8 +980,8 @@ SafeConfigParser Objects
.. method:: set(section, option, value)
If the given section exists, set the given option to the specified value;
- otherwise raise :exc:`NoSectionError`. *value* must be a string; if not,
- :exc:`TypeError` is raised.
+ otherwise raise :exc:`NoSectionError`. *option* and *value* must be
+ strings; if not, :exc:`TypeError` is raised.
.. method:: write(fileobject, space_around_delimiters=True)
@@ -1044,7 +1048,7 @@ RawConfigParser Objects
.. class:: RawConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=_COMPATIBLE, strict=False, empty_lines_in_values=True, default_section=configaparser.DEFAULTSECT, interpolation=None)
Legacy variant of the :class:`SafeConfigParser` with interpolation disabled
- by default and an unsafe ``set`` method.
+ by default and unsafe ``add_section`` and ``set`` methods.
.. note::
Consider using :class:`SafeConfigParser` instead which checks types of
@@ -1052,6 +1056,16 @@ RawConfigParser Objects
can use ``SafeConfigParser(interpolation=None)``.
+ .. method:: add_section(section)
+
+ Add a section named *section* to the instance. If a section by the given
+ name already exists, :exc:`DuplicateSectionError` is raised. If the
+ *default section* name is passed, :exc:`ValueError` is raised.
+
+ Type of *section* is not checked which lets users create non-string named
+ sections. This behaviour is unsupported and may cause internal errors.
+
+
.. method:: set(section, option, value)
If the given section exists, set the given option to the specified value;