summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2010-12-04 12:46:01 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2010-12-04 12:46:01 (GMT)
commit2cf9ddb390564046242d7b0c5667c62843e74714 (patch)
treeda6760e3fc78c4c8ffd0ca914c173359e8793c5d /Doc/library
parentd2a9b20efaa15b0152856a545b0206af21d06c5e (diff)
downloadcpython-2cf9ddb390564046242d7b0c5667c62843e74714.zip
cpython-2cf9ddb390564046242d7b0c5667c62843e74714.tar.gz
cpython-2cf9ddb390564046242d7b0c5667c62843e74714.tar.bz2
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')
-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 6822176..154d062 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;