Skip to content

bpo-27351: Fix ConfigParser.read() documentation and docstring #8123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -963,16 +963,17 @@ ConfigParser Objects

.. method:: read(filenames, encoding=None)

Attempt to read and parse a list of filenames, returning a list of
Attempt to read and parse an iterable of filenames, returning a list of
filenames which were successfully parsed.

If *filenames* is a string, a :class:`bytes` object or a
:term:`path-like object`, it is treated as
a single filename. If a file named in *filenames* cannot be opened, that
file will be ignored. This is designed so that you can specify a list of
potential configuration file locations (for example, the current
directory, the user's home directory, and some system-wide directory),
and all existing configuration files in the list will be read.
file will be ignored. This is designed so that you can specify an
iterable of potential configuration file locations (for example, the
current directory, the user's home directory, and some system-wide
directory), and all existing configuration files in the iterable will be
read.

If none of the named files exist, the :class:`ConfigParser`
instance will contain an empty dataset. An application which requires
Expand Down
8 changes: 4 additions & 4 deletions Lib/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
Return list of configuration options for the named section.

read(filenames, encoding=None)
Read and parse the list of named configuration files, given by
Read and parse the iterable of named configuration files, given by
name. A single filename is also allowed. Non-existing files
are ignored. Return list of successfully read files.

Expand Down Expand Up @@ -677,13 +677,13 @@ def options(self, section):
return list(opts.keys())

def read(self, filenames, encoding=None):
"""Read and parse a filename or a list of filenames.
"""Read and parse a filename or an iterable of filenames.

Files that cannot be opened are silently ignored; this is
designed so that you can specify a list of potential
designed so that you can specify an iterable of potential
configuration file locations (e.g. current directory, user's
home directory, systemwide directory), and all existing
configuration files in the list will be read. A single
configuration files in the iterable will be read. A single
filename may also be given.

Return list of successfully read files.
Expand Down