mirror of
https://github.com/python/cpython.git
synced 2025-10-05 06:31:48 +00:00
bpo-41963: document that ConfigParser strips off comments (GH-26197) (GH-26213)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Laura Gutierrez Funderburk <58710704+lgfunderburk@users.noreply.github.com>
Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
(cherry picked from commit 02ee819126
)
This commit is contained in:
parent
c05d8a6b67
commit
c17ba233b3
3 changed files with 12 additions and 1 deletions
|
@ -1129,6 +1129,13 @@ ConfigParser Objects
|
||||||
*space_around_delimiters* is true, delimiters between
|
*space_around_delimiters* is true, delimiters between
|
||||||
keys and values are surrounded by spaces.
|
keys and values are surrounded by spaces.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Comments in the original configuration file are not preserved when
|
||||||
|
writing the configuration back.
|
||||||
|
What is considered a comment, depends on the given values for
|
||||||
|
*comment_prefix* and *inline_comment_prefix*.
|
||||||
|
|
||||||
|
|
||||||
.. method:: remove_option(section, option)
|
.. method:: remove_option(section, option)
|
||||||
|
|
||||||
|
|
|
@ -907,6 +907,9 @@ class RawConfigParser(MutableMapping):
|
||||||
|
|
||||||
If `space_around_delimiters' is True (the default), delimiters
|
If `space_around_delimiters' is True (the default), delimiters
|
||||||
between keys and values are surrounded by spaces.
|
between keys and values are surrounded by spaces.
|
||||||
|
|
||||||
|
Please note that comments in the original configuration file are not
|
||||||
|
preserved when writing the configuration back.
|
||||||
"""
|
"""
|
||||||
if space_around_delimiters:
|
if space_around_delimiters:
|
||||||
d = " {} ".format(self._delimiters[0])
|
d = " {} ".format(self._delimiters[0])
|
||||||
|
@ -1005,7 +1008,7 @@ class RawConfigParser(MutableMapping):
|
||||||
Configuration files may include comments, prefixed by specific
|
Configuration files may include comments, prefixed by specific
|
||||||
characters (`#' and `;' by default). Comments may appear on their own
|
characters (`#' and `;' by default). Comments may appear on their own
|
||||||
in an otherwise empty line or may be entered in lines holding values or
|
in an otherwise empty line or may be entered in lines holding values or
|
||||||
section names.
|
section names. Please note that comments get stripped off when reading configuration files.
|
||||||
"""
|
"""
|
||||||
elements_added = set()
|
elements_added = set()
|
||||||
cursect = None # None, or a dictionary
|
cursect = None # None, or a dictionary
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Document that ``ConfigParser`` strips off comments when reading configuration files.
|
Loading…
Add table
Add a link
Reference in a new issue