[issue35448] ConfigParser .read() - handling of nonexistent files

Serhiy Storchaka report at bugs.python.org
Mon Oct 28 12:17:21 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

> There is a use case of this (which some of tools depends) about checking if configuration exists and if not, raising an error. Now, they can solve this by just adding check_exist argument.

No, it can be solved by using open() and read_file(). It can also be solved by checking the result of read(), as Victor suggested. Your proposition adds third way, but unlike to the first two it could be used only in new Python versions.

> Can you give an example of how this feature can/could break existing code?

You pass a list containing user configuration path, system-wide configuration path, and default configuration path (it can contain also per-directory configuration path). At first run of your program there is no user configuration file.

> For me, a better option would be to be able to pass an open file to configparser. So the caller can decide how to handle the open() error.

There is the read_file() method which accept an open file.

----------
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35448>
_______________________________________


More information about the Python-bugs-list mailing list